How to avoid webmap reset when executing wmline? (AKA: how to visualize a colored line that refreshes every second on a map)

3 Ansichten (letzte 30 Tage)
I'm writing a script that plots geotagged data on a webmap and refreshes every second. I followed the method proposed here, and everything works fine: http://it.mathworks.com/help/supportpkg/mobilesensor/examples/acquire-gps-data-from-your-android-device-and-plot-your-location-and-speed-on-a-map.html
I implemented a loop to re-draw the line with the new data every second (for 6 seconds):
% Open the map
wm = webmap('MapQuest Open Street Map');
zoom = 17;
% Obtain initial data from arduino and store it in vectors
[lat(1), lon(1), lum(1)] = readGPS(arduino);
lat(1) = lat(1)/10^4;
lon(1) = lon(1)/10^4;
for i=2:1:6
% Obtain data from arduino and store it in vectors
[lat(i,1), lon(i,1), lum(i,1)] = readGPS(arduino);
lat(i,1) = lat(i,1)/10^4;
lon(i,1) = lon(i,1)/10^4;
% Prepare the data in a geoshape
s = ComputeBins(nBins,lat,lon,lum);
%Remove previous line
wmremove()
% Print the line
wmline(wm, s, 'Color', colors, 'Width', 5, 'OverlayName', 'Parameter');
% Center the visual to the last datapoint
wmcenter(lat(end),lon(end), zoom);
pause(1)
end
The problem is that every time wmline() is executed, the zoom and center of the map change. This makes the map impossible to look at, since it is continuously refreshing and zooming in and out.
Question: How can I prevent wmline from changing the zoom and center of the webmap?
Thankyou for your help.
PS: if you think that there is a better way to display this kind of data (a colored line on a map that refreshes every second), I'm glad to try different and better solutions.

Antworten (1)

Amy Haskins
Amy Haskins am 1 Mai 2015
There's an auto fit option that you can turn off to avoid the zooming and re-centering:
wmline([0 20],[0 150],'AutoFit',false)

Community Treasure Hunt

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

Start Hunting!

Translated by