Skip to main content
Question

Get bounding box Zoom level to fetch static MAP

  • July 14, 2020
  • 3 replies
  • 137 views

boubcher
Contributor
Forum|alt.badge.img+11

Hello There

we are using Google static MAp Api in order to fetch static MAP for the line

since the api take the center point we thought we should use the bounding Box, get the center from there, but we are missing the zome level that should cover the entire line

https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400&key=YOUR_API_KEY

 

we are using image fetcher transformer

or do you have any other way to do it

 

0684Q00000ArAeqQAF.gif

Thanks

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • July 14, 2020

So the pixel resolution of a given tile should be 360/256^Zoom.

If you divide the size of the static image (400 in the example) by the size of the bounding box, you should get your expected resolution, then it's just a matter of determining the closest zoom level.

 

 

This assumes your bounding box is in decimal degrees, the equation becomes a little more complicated if you are working in a metered projection.


jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • July 14, 2020

So the pixel resolution of a given tile should be 360/256^Zoom.

If you divide the size of the static image (400 in the example) by the size of the bounding box, you should get your expected resolution, then it's just a matter of determining the closest zoom level.

 

 

This assumes your bounding box is in decimal degrees, the equation becomes a little more complicated if you are working in a metered projection.

If I did the math correctly (and I'm uncaffeinated for 9 days, so no promises) this equation should be:

 

_zoom = @log(360*@Value(_size)/(@Value(_xmax)-@Value(_xmin)))/@log(2) - 8

 

 

where _size is the output image size (400 in the example)

 

 


boubcher
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 212 replies
  • July 14, 2020

If I did the math correctly (and I'm uncaffeinated for 9 days, so no promises) this equation should be:

 

_zoom = @log(360*@Value(_size)/(@Value(_xmax)-@Value(_xmin)))/@log(2) - 8

 

 

where _size is the output image size (400 in the example)

 

 

@jdh

Thanks great

Its works