Get static image from Google map for given area -


i know google maps provides api getting static images:

https://developers.google.com/maps/documentation/static-maps/intro

however api gets input center point, zoom level , output image size.

in case, need image fits given area taking input nw (top-left) , se (bottom right) coordinates describing rectangle of area. don't see option within google maps api, i'm wondering if there way accomplish this.

you can omit center , zoom parameters if specify @ least 1 marker. in case can show area marker.

for example, have bounds of barcelona in spain:

41.320004,2.069526 , 41.469576,2.22801

i can calculate center position of bounds:

41.39479,2.148768

now, let's put marker in center of bounds , use visible parameter of static maps api specify nw , se.

visible (optional) specifies 1 or more locations should remain visible on map, though no markers or other indicators displayed. use parameter ensure features or map locations shown on google static maps api.

https://maps.googleapis.com/maps/api/staticmap?size=600x400&markers=icon%3ahttp%3a%2f%2fwww.google.com%2fmapfiles%2farrow.png%7c41.39479%2c2.148768&visible=41.320004%2c2.069526%7c41.469576%2c2.22801&key=api_key

code snippet

<img src="https://maps.googleapis.com/maps/api/staticmap?size=600x400&markers=icon%3ahttp%3a%2f%2fwww.google.com%2fmapfiles%2farrow.png%7c41.39479%2c2.148768&visible=41.320004%2c2.069526%7c41.469576%2c2.22801" title="" />

as result, have image specified area. think can go further if create transparent png file marker icon.

hope helps!


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -