フィルターのクリア

How To Add Layers Onto A Map (GUI)

2 ビュー (過去 30 日間)
Mark M
Mark M 2017 年 7 月 11 日
回答済み: Geoff Hayes 2017 年 7 月 12 日
Hello,
My goal is to overlay different data points onto the same map, for example if the user selects Option 1 and Option 3 I want both of those "layers" to show on the map.
I thought the best way to do this would be through the use of checkboxes, and have the code run through and check for the result of each checkbox. If the value of a checkbox was 1, then the corresponding layer would be added to the image.
I figured that I would need to create a separate "image" for each option of just the points to lay over the map, but I'm not sure if that would be the best way.
Can someone please help me with this? I am not sure if it is possible, but I sure hope so because it will be perfect for my work.

回答 (1 件)

Geoff Hayes
Geoff Hayes 2017 年 7 月 12 日
Mark - I think that you have the right idea. Your layer could just be a handle to a graphics object that you show or hide depending upon the state of the checkbox. For example, a checkbox callback could do
function checkbox1_Callback(hObject, eventdata, handles)
if get(hObject, 'Value') == 0
if isfield(handles,'hSin')
set(handles.hSin, 'Visible', 'off');
end
else
if isfield(handles,'hSin')
set(handles.hSin, 'Visible', 'on');
else
x = 0:0.01:8*pi;
y = 30*sin(x) + 30;
handles.hSin = plot(x,y, 'r.');
guidata(hObject, handles);
end
end
The above code (from a GUIDE-created GUI) shows or hides a sine curve based on the state/value of the checkbox. See the attached GUI for an example of a GUI that displays two curves (sets of points) over an image.

製品

Community Treasure Hunt

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

Start Hunting!

Translated by