How to incorporate axesm-based maps in an app

조회 수: 2 (최근 30일)
Kurt
Kurt 2023년 12월 22일
댓글: Kurt 2024년 1월 3일
I am interested in creating axesm-based maps:
h = axesm('MapProjection','mercator')
However, there appears to be no way to tie the axesm object back to a parent app container:
h = axesm(app,'MapProjection','mercator') % doesn't work
I need to reference the various app components, for example:
app.panel.earth = axesm(app.panel,"Geoid",grs80, "Grid", "on"); % or something
There are lots of examples of how to use the other axes(), but not so much for axesm.
I intend to create, move and destroy lines in the app. I know how to do this in a UIAxes component, storing the line segments in Children. But axesm still throws me. I started with this example, but now I need to fold it into a GUI app:

채택된 답변

Walter Roberson
Walter Roberson 2023년 12월 22일
There is no straight-forward way of doing this. axesm() does not have anything similar to a 'Parent' property. axesm() is written in terms of gca
To use axesm with a uifigure() you need to work around the fact that uifigure HandleVisibility is Off
fig = ancestor(app.panel, 'figure');
fig.HandleVisibility = 'on';
Then you have to have an axes within the panel, and make it the current axes
ax = findobj(app.panel, 'type', 'axes');
if isempty(ax)
ax = axes(app.panel);
end
fig.CurrentAxes = ax(1);
Then you can axesm
h = axesm('MapProjection','mercator');
  댓글 수: 1
Kurt
Kurt 2024년 1월 3일
This is great! Encapsulating the axesm() with an axes makes it dual-purpose, and I can do UIAxes-type functions on it. Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by