Drop Down and geoshow

6 views (last 30 days)
Gogu
Gogu on 19 Dec 2020
Commented: Gogu on 21 Dec 2020
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

Accepted Answer

Mario Malic
Mario Malic on 20 Dec 2020
Edited: Mario Malic on 20 Dec 2020
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 Comment
Gogu
Gogu on 21 Dec 2020
Thank you very much !
Now works fine....
Merry Christmas !

Sign in to comment.

More Answers (0)

Categories

Find more on Geographic Plots in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!