Drop Down and geoshow
1 次查看(过去 30 天)
显示 更早的评论
Hello !
I have an interface (GUI) that includes: Drop Down, Axes
In Drop Down I have 2 options: Map1, Map2
If you select Map1, it should display map1.shp; if you select Map2, it should display map2.shp
At startup, map1.shp is displayed
Problem: If I select Map2, it displays map2.shp correctly, but if I select Map1, nothing happens.
function startupFcn(app)
s=shaperead('C:\Users\Vostro\Desktop\App_Maps\Map1\map1.shp');
geoshow(app.UIAxes,s);
end
% Value changed function: SelecteazaHartaDropDown
function SelecteazaHartaDropDownValueChanged(app, event)
value = app.SelecteazaHartaDropDown.Value;
switch value
case 'Harta1'
s=shaperead('C:\Users\Vostro\Desktop\App_Maps\Map1\map1.shp');
geoshow(app.UIAxes,s);
case 'Harta2'
s=shaperead('C:\Users\Vostro\Desktop\App_Maps\Map2\map2.shp');
geoshow(app.UIAxes,s);
end
end
0 个评论
采纳的回答
Mario Malic
2020-12-20
编辑:Mario Malic
2020-12-20
I am not seeing the issue with your code, but it could be improved a bit. Your initial value on the dropdown is the first one - 'Harta1', and if you opened the dropdown menu and pressed it again callback won't be executed, but that's not an issue because you have already loaded Harta1 in the startupFcn.
Better way to do it is by having an intial option that tells you to choose the map, as a result, you don't have to have the startupFcn anymore.
% Value changed function: SelecteazaHartaDropDown
function SelecteazaHartaDropDownValueChanged(app, event)
value = app.SelecteazaHartaDropDown.Value;
switch value
case 'Please select the map'
cla(app.UIAxes)
case 'Harta1'
s=shaperead('C:\Users\Vostro\Desktop\App_Maps\Map1\map1.shp');
geoshow(app.UIAxes,s);
case 'Harta2'
s=shaperead('C:\Users\Vostro\Desktop\App_Maps\Map2\map2.shp');
geoshow(app.UIAxes,s);
end
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!