MATLAB: How to draw map in app designer

appdesignermapMATLABuiaxesworldmap

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?
Thanks!

Best Answer

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()