zoharby/plot_google​_map

버전 2.0.0.1 (12.6 KB) 작성자: Zohar Bar-Yehuda
Plot a google map on the background of the current figure using the Static Google Maps API.
다운로드 수: 31K
업데이트 날짜: 2020/4/22

편집자 메모: This file was selected as MATLAB Central Pick of the Week

plot_google_map.m uses the Google Maps API to plot a map in the background of the current figure.
It assumes the coordinates of the current figure are in the WGS84 datum, and uses a conversion code to convert and project the image from the coordinate system used by Google into WGS84 coordinates.
The zoom level of the map is automatically determined to cover the entire area of the figure. Additionally, it has the option to auto-refresh the map upon zooming in the figure, revealing more details as one zooms in.
The following code produces the screenshot:
plot_google_map('apiKey', '<Your_API_Key>') % You only need to run this once, which will store the API key in a mat file for all future usages
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('MapScale', 1)

Prerequisites
Due to changes to the Google Maps billing model, you now must set your own Google Maps API key and enable billing for your project. You're getting an automatic credit of 200$/month, which will be enough for 100,000 static maps calls without actually being billed.

Note that this does pose some challenges if you want to deploy your code, as your API key will need to be deployed with the code / as a mat file and hence may be exposed to users.

Known Issues:
1) Saving the map with an image/matrix overlay drawn on top of it (especially a semi-transparent one) can sometimes cause unexpected results (map not showing etc.). If you're encountering such problems, it's recommended to use the export_fig submission:
http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig
The combination that seems to work best:
set(gcf,'renderer','zbuffer')
export_fig('out.jpg')

인용 양식

Zohar Bar-Yehuda (2024). zoharby/plot_google_map (https://github.com/zoharby/plot_google_map), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2009b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!

GitHub 디폴트 브랜치를 사용하는 버전은 다운로드할 수 없음

버전 게시됨 릴리스 정보
2.0.0.1

Update description to reflect Google billing chnages

2.0.0.0

Added an option to show a scale indicator on the map

1.9.0.0

Version 1.6 - 12/11/2015
- Use system temp folder for writing image files (with fallback to current dir if missing write permissions)

1.8.0.0

Revert description

1.6.0.0

known issues (map saving alternative with export_fig)

1.5.0.0

Version 1.4 - 25/03/2014
- Added the language parameter for showing labels in a local language
- Display the URL on error to allow easier debugging of API errors

1.4.0.0

- Improved functionality of AutoAxis, which now handles any shape of map axes.
Now also updates the extent of the map if the figure is resized.
- Added the ShowLabels param which allows hiding the textual labels on the map.

1.2.0.0

- Support use of the "scale=2" parameter by default for finer rendering (set scale=1 if too slow).
- Auto-adjust axis extent so the map isn't stretched.
- Set and use an API key which enables a much higher usage volume per day.

1.0.0.0

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.