Skip to main content
Question

Get bounding box Zoom level to fetch static MAP


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

3 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • 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+28
  • Contributor
  • July 14, 2020
jdh wrote:

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
  • July 14, 2020
jdh wrote:

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

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings