how to draw map in app designer?

32 views (last 30 days)
YC on 9 Aug 2019
Commented: Adam Danz on 4 Jun 2021
hi, I was trying to draw a map in app desinger
worldmap(app.UIAxes,'World'); but it reports error message.
so I searched and found there is one post saying that map axes cannot be used in uifigures.
If i really want to plot a map and some other points with lat/lon on the axes of the add designer (which makes the app look more professional), is there any work around?
YC on 9 Aug 2019
sorry, the code is just one single line:
function PlotButtonPushed3(app, event)
the error message is the same as you just posted, thank you!

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 9 Aug 2019
There is no axes input to the worldmap function (unfortunately). The function will create a new figure to display the map. After the figure is created, you can copy it to your app axes and then delete the figure created by worldmap().
h = worldmap('World'); % Store the output handle!
hCopy = copyobj(h.Children, app.UIAxes); % Copy all of the axis' children to your app axis
delete(h.Parent) % get rid of the figure created by worldmap()
Adam Danz
Adam Danz on 4 Jun 2021
I could not reproduce the same problem you described with the code you provided.
latlim = [10 30];
longlim = [50 100];
ax = worldmap(latlim,longlim);
app.UIFigure = uifigure();
app.UIAxes = uiaxes(app.UIFigure,'Position',[60 60 400 300]);
axcopy = copyobj(ax.Children,app.UIAxes);
Notice how the map axes are rendered. You can remove the background axes using,
app.UIAxes.Visible = 'off';
Please post a new question if you need any further help.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!