Plot latitude and longitude on google map

67 views (last 30 days)
I have set of latitude and longitude data need to plot real time.
Read values from .csv file
plot(lon1(1:i),lat1(1:i),'bo-');
pause(0.1);
drawnow
Following are set of values need to plot on google map.
33.87381314 -118.38231
33.87381315 -118.3823182
33.87381315 -118.3823263
33.87381316 -118.3823345
33.87381316 -118.3823429
33.87381317 -118.3823513
33.87381317 -118.3823598
33.87381318 -118.3823679
33.87381318 -118.3823761
33.87381319 -118.3823842
33.87381319 -118.3823926
33.8738132 -118.3824011
33.8738132 -118.3824098
33.87381321 -118.3824185
33.87381321 -118.3824276
33.87381322 -118.3824366
33.87381322 -118.3824454
33.87381323 -118.3824538
33.87381323 -118.3824623
33.87381324 -118.3824707
33.87381324 -118.3824794
33.87381325 -118.3824885
33.87381325 -118.3824972
33.87381326 -118.3825057
33.87381326 -118.3825144
33.87381327 -118.3825234
33.87381327 -118.3825325
33.87381328 -118.3825415
33.87381328 -118.3825506
33.87381329 -118.3825596
33.87381329 -118.3825687
33.8738133 -118.3825774
33.8738133 -118.3825858
33.87381331 -118.382594
33.87381331 -118.3826024
33.87381332 -118.3826105
33.87381332 -118.3826187
33.87381333 -118.3826268
33.87381333 -118.382635
33.87381334 -118.3826431
33.87381334 -118.3826512
33.87381335 -118.3826594
33.87381335 -118.3826675
33.87381336 -118.382676
33.87381336 -118.3826847
33.87381337 -118.3826934
33.87381337 -118.3827025
33.87381338 -118.3827115
33.87381338 -118.3827206
33.87381339 -118.3827293

Answers (3)

cui,xingxing
cui,xingxing on 4 Apr 2020
Use matlab mobile to record the sensor data or your data, and then use the following code to draw (requires mapping toolbox)):
load('sensorlog_20200402_193813.mat');
latitude = Position.latitude;
longitude = Position.longitude;
%%
wm = webmap('World Imagery');
s = geoshape(latitude,longitude);
wmline(s,'Color', 'red', 'Width', 3);

KSSV
KSSV on 20 Feb 2019
  4 Comments
Manoj Pai
Manoj Pai on 20 Feb 2019
I have ensured, I have good internet connection.
Sjors Huijbers
Sjors Huijbers on 22 May 2019
To debug, try pasting the following URL in your browser, which may result in a more informative error:
Check if you can access this map. If not, your API key for google static maps is missing. You will have to buy one.

Sign in to comment.


MathWorks Support Team
MathWorks Support Team on 11 Jul 2023
You can plot latitude and longitude data onto a basemap using geoplot or geoscatter. You can also update the basemap using geobasemapor add a custom basemap using addCustomBasemap. Here is an example to plot the first six points:
lat = [33.87381314 33.87381315 33.87381315 33.87381316 33.87381316 33.87381317];
lon = [-118.38231 -118.3823182 -118.3823263 -118.3823345 -118.3823429 -118.3823513];
geoplot(lat,lon,"Marker","o")
geobasemap streets

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!