Problem with Web Map

5 次查看(过去 30 天)
Roberto Revelli
Roberto Revelli 2022-7-13
编辑: Siraj 2023-9-15
Hello, I'm trying to upload several gpx traces on a web map. The basic code is
webmap('worldimagery')
for i=1:n_route
wmline(route{i});
end
whre route is a cell array with n_route gpx traces.
The for-loop cracks after 12-15 loops and the following error appears "The web map page has not finished loading."
Many thanks for any suggestion!
  2 个评论
Geoff Hayes
Geoff Hayes 2022-7-14
@Roberto Revelli - perhaps you need to pause on each iteration of the loop to give the app time to draw the line...rather than trying to draw each line one after the other. I'm just guessing here as I don't have the Mapping Toolbox to reproduce the behaviour.
Roberto Revelli
Roberto Revelli 2022-7-14
Thanks @Geoff Hayes.
I've already tried with pause(...) in the for-loop after the wmline command, but error comes anyway. I'd like to find a more stable solution.
Roberto

请先登录,再进行评论。

回答(1 个)

Siraj
Siraj 2023-9-15
编辑:Siraj 2023-9-15
Hi!
It is my understanding that you want to draw multiple lines on a web map using the "wmline" function in MATLAB. However, when the number of lines becomes larger, the following error is encountered.
"The web map page has not finished loading."
I suspect that it is a memory issue. As the number of lines to be drawn on the web map increases, it consumes more memory and eventually leads to the error.
As a workaround you can put all the line coordinates into a geoshape and then use one call to “wmline”. This is significantly faster.
Refer to the provided code for a clearer understanding and feel free to modify it according to your specific requirements. In this example, the code draws 500 circles on a web map.
% Define the center coordinates
lat0 = 51.50487;
lon0 = 0.05235;
% Open the web map using OpenStreetMap as the base map
webmap('OpenStreetMap')
% Initialize an empty array to store azimuth values
az = [];
% Define the reference ellipsoid
e = wgs84Ellipsoid;
% Start measuring the execution time
tic
% Loop to create circles with increasing radii
for i = 1:500
% Calculate the radius based on the loop index
radius = 10 * i;
% Calculate the latitude and longitude coordinates of the circle
[lat, lon] = scircle1(lat0, lon0, radius, az, e);
% Generate a name for the circle based on its radius
name = sprintf('%d Meters', radius);
% Create a geoshape object representing the circle
s(i) = geoshape(lat, lon, "Name", name);
end
% Draw all the circles as a single line on the web map
wmline(s, 'Color', 'k', 'OverlayName', '1:500 lines (meters)')
% Stop measuring the execution time and display it
toc
For more detailed information about the "geoshape" object and the "wmline" function, you can refer to the following links:
These resources provide comprehensive explanations and usage examples for the "geoshape" object and the "wmline" function in MATLAB.
Hope this helps.

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by