Sunday, July 30, 2017

[Matlab] Plot the latitude and longitude information on Google Map

Source URL
1. https://www.mathworks.com/matlabcentral/fileexchange/27627-zoharby-plot-google-map
2. https://blogs.mathworks.com/pick/2012/05/04/plot-google-map/

Can download the function 'plot_google_map' from the source URL 1.

Example code 1.
lat = [48.8708 51.5188 41.9260 40.4312 52.523 37.982];
lon = [2.4131 -0.1300 12.4951 -3.6788 13.415 23.715];
plot(lon,lat,'.r','MarkerSize',20)
plot_google_map

Result 1
The result appears on new figure.

Example code 2
% load route data
load NatickToBOS

% plot route data
plot(Data001(:, 1), Data001(:, 2), 'r', 'LineWidth', 2);
line(Data001(1, 1), Data001(1, 2), 'Marker', 'o', ...
    'Color', 'b', 'MarkerFaceColor', 'b', 'MarkerSize', 10);
line(Data001(end, 1), Data001(end, 2), 'Marker', 's', ...
    'Color', 'b', 'MarkerFaceColor', 'b', 'MarkerSize', 10);
xlim([-71.4, -71]); axis equal off

% Google map
plot_google_map('maptype', 'roadmap');

zoomHandle = zoom;
set(zoomHandle, 'ActionPostCallback', @update_google_map);

Result 2
The result appears on new figure.



No comments:

Post a Comment