Drop Down and geoshow

1 次查看(过去 30 天)
Gogu
Gogu 2020-12-19
评论: Gogu 2020-12-21
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

采纳的回答

Mario Malic
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
  1 个评论
Gogu
Gogu 2020-12-21
Thank you very much !
Now works fine....
Merry Christmas !

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by