How to use tree function from App designer to trigger a map/plot on and off

2 ビュー (過去 30 日間)
Surafel
Surafel 2023 年 1 月 23 日
コメント済み: Surafel 2023 年 1 月 27 日
I am running an app that has to incorporate a map. I am using a base map and I will do the task on top of that. So I used a "tree" function. And using the code below I am able to draw the map inside my canvas.
geoaxes(app.UIFigure,'Basemap','streets')
  1. I have two main questions, when I select the tree the map will show but when I unselect it the map still shows there.
2. Second question is when I am runnding the code out side of this app designer I can fetch the latitude and longitude of the map but not here. Because on this application I want to fetch latitude and longitude (that will be used for processing later)
I dont know what is wrong here so I didnt know how to approach it
3. and finally I have also tried moving the map inside the canvas using "guimove" but I am able to move the whole window not the map inside the canvas. just looking if there is a special function.
I did
gx = geoaxes(app.UIFigure,'Basemap','streets')
guimove('gx', 'right')

回答 (1 件)

Kevin Holly
Kevin Holly 2023 年 1 月 24 日
  1. Have you tried cla?
  2. You can obtain this information from the axes handle. See below. Notice handle is saved as variable h.
  3. Use geolimits. See below for an example. Note, running these lines on my desktop MATLAB did not change the Latitude coordinates.
fig = figure; % Using figure because uifigure is not supported on this site, but it should work for uifigure as well (App designer uses uifigure).
h = geoaxes(fig,'Basemap','streets');
geolimits(h,[-60 60],[-30 30]);
h.LatitudeLimits
ans = 1×2
-60.0000 60.0000
h.LongitudeLimits
ans = 1×2
-95.5493 95.5493
fig = figure; % Using figure because uifigure is not supported on this site, but it should work for uifigure as well (App designer uses uifigure).
h = geoaxes(fig,'Basemap','streets');
geolimits(h,[-60 60],[-30 30]);
geolimits(h,[h.LatitudeLimits],[h.LongitudeLimits(1) h.LongitudeLimits(2)+40])
h.LatitudeLimits
ans = 1×2
-67.0066 67.0066
h.LongitudeLimits
ans = 1×2
-95.5493 135.5493
  1 件のコメント
Surafel
Surafel 2023 年 1 月 27 日
Thanks Kevin, so for the second question. I am trying generate a gpx file because Matlab can only read but not write a gpx file (I am not sure its just I can not find it on the documentation)
so my approach is I wanted to do a geoplot () ... draw a line between two points then use datatip to fetch all the latitude and longitude between the points (or latitude and longitude on the line) then save it to a variable to fetch the poiints later. (I already have a python script to generate the gpx). But I would need the values from matlab first. However it is not working and my question was if there is a better way to do it. And thank you for replying the other questions are answered.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDevelop uifigure-Based Apps についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by