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