Question

How can I work out the width(in degrees and minutes) of a Google Static Maps image?

For example if I request a static map with a centre of -32 Lat 151 Long(Australia Sydney) and a zoom value of 14 how can I determine the width of that satellite image returned?

http://maps.googleapis.com/maps/api/staticmap?center=-32,151&zoom=14&size=400x400&sensor=true

What would be the real world width and height of the image returned?

I know the centre is -32, 151 and the zoom level is 14. Maybe zoom=14 represents an altitude of 14000 metres? If so I can work out the real world dimensions using maths but I'm not so sure thats what the '14' equates to.

This SO Question looked very promising but alas no answers for them: Google Static Maps Dimension Discrepancy

Était-ce utile?

La solution

If you're not interested in measured distances [miles or km], but only spherical distances [degrees], the calculation is not difficult.

At zoom level zero, the entire 360° of the equator fits into 256px. At zoom 1, it's 360÷2=180°. At zoom 14, it's 360÷214 = 0.021973° (approximately).

widthDeg = (elementWidthInPixels/256)*(360 / Math.pow(2,zoom))

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top