Drop Down and geoshow

4 ビュー (過去 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 Center および File ExchangeMapping Toolbox についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by