Map Scale: Distance in Meters to Pixels depending on Zoom level

Took me a while to wrap my head around this: I tried to draw a circle around a specific coordinate (latitude & longitude) on a (google maps like) map.
My first attempt was:
EARTH_CIRCUMFERENCE / 2 ^ ZOOM_LEVEL / TILE_SIZE

which resulted in a circle whose radius was off by about 20% in my tests. ( South Germany; 500m radius ).

of course I had to factor in that this assumes we’re on the equator. To account the current latitude (for the circles’center) I modified the formula:

EARTH_CIRCUMFERENCE * cos(Latitude * PI / 180) / 2 ^ ZOOM_LEVEL / TILE_SIZE

Dieser Eintrag wurde veröffentlicht in Ohne Kategorie Getagged: , . Bookmarken: Permanent-Link. Kommentieren oder ein Trackback hinterlassen: Trackback-URL.

Ihr Kommentar

Ihre E-Mail wird niemals veröffentlicht oder verteilt. Benötigte Felder sind mit * markiert

*
*

Du kannst diese HTML Tags und Attribute verwenden: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">