get_google_map

버전 1.4.0.0 (7.62 KB) 작성자: Val Schmidt
Retrieve a google map from the command line using the Static Google Maps API.
다운로드 수: 11.7K
업데이트 날짜: 2016/3/25

라이선스 보기

The function get_google_map.m uses the Google Maps API (https://developers.google.com/maps/documentation/static-maps/) to retrieve a google map image from Google given coordinates of the center of the image and the desired zoom level (default 15). The image is returned as a raster array and a color map.
In addition, an estimate of the X and Y coordinate vectors are returned in UTM coordinates to facilitate easy plotting of additional information on the map from within MATLAB.
The desired height and width of the image (in pixels) may be specified as well as the "MapType" (one of roadmap, mobile, satellite, terrain, hybrid, mapmaker-roadmap, mapmaker-hybrid) and up to 50 Google Map markers. For each marker one may specify the location, size, color and optional label.
Default values: Zoom 15, MapType = 'satellite', Height = 640, Width = 640
One may utilize the Google Maps API without a key for a limited number of queries per day. To utilize the Google Maps API up to 25,000 queries per day, one must obtain a Google Maps API Key, freely available from Google. The key may be obtained here: https://developers.google.com/maps/documentation/static-maps/ (click "Get a Key")

Note, the key requirement places limitations on the portability of this function, as the key, and therefore the function is necessarily tied to a domain name and therefore (usually) a physical location. None-the-less it remains a very handy function for quickly plotting data on a map.

The following code produce the attached screenshot:

[xx yy M Mcolor] = get_google_map(43.06374,-70.703993);
imagesc(XX,YY,M); shading flat; colormap(Mcolor)
xlabel('Eastings UTM')
ylabel('Northings UTM')
title('Entrance to Portsmouth Harbor')

Known Issues:
1) The estimate of the X and Y coordinate vectors are just that, a guess at an algorithm for determining these values from the images size and zoom level. The algorithm was determined by trial and error (as the API provides no way to query for the spacial bounds of an image), and therefore will likely produce poor results for some locations. In the vicinity of Portsmouth Harbor, NH the resulting image is geo-referenced to about +/- 3m.

2) Because of MATLAB's poor rendering performance on the Mac platform, my experience has been that maps plotted as in the example above produce white gaps whose cause and resolution are unknown.

인용 양식

Val Schmidt (2024). get_google_map (https://www.mathworks.com/matlabcentral/fileexchange/24113-get_google_map), MATLAB Central File Exchange. 검색 날짜: .

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

도움 받은 파일: deg2utm, zoharby/plot_google_map

도움 준 파일: zoharby/plot_google_map

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.4.0.0

Adopted Martin's suggestion (see comments) to use a webread() call rather than a temporary file. Also reorganized the code a bit to make more understandable.

1.3.0.0

Adopted Google Maps API Key handling from plot_google_map(). Updated to use the new Google Maps API. Uses a new method (requiring the signal processing toolbox) for calibrating the image size.

1.2.0.0

No functional change.

1.1.0.0

I've taken the recommendations made by "us", removing flipud from the code so the resulting image plots with imagesc correctly and making the options case insensitive.

1.0.0.0