[OSM-dev] Plotting a point on a tile

Martijn van Oosterhout kleptog at gmail.com
Sat Aug 16 15:05:08 BST 2008


On Fri, Aug 15, 2008 at 9:46 AM, Water Explorer Support
<support at waterexplorer.co.uk> wrote:
> I can calculate and display the tiles without any issues, but the problem
> I'm having is actually plotting a point accurately on the tile.
>
> Heres what I do so far:
>
> Assume: Latitude = 52.478624 and Longitude= -1.913584 which is the centre of
> Birmingham, UK.
>
> Using the code supplied on
> http://wiki.openstreetmap.org/index.php/Slippy_map_tilenames#Tiles
>
> I can calculate that at zoom level 18, my x and y tiles are 129678 and
> 86020, so I get a tile URL of
> http://tile.openstreetmap.org/mapnik/18/129678/86020.png

You're really close: those formulae at some point truncate the number
they get to an integer, raw they produce something like 129678.xxx and
86020.yyy. If you take those fractional parts and multiply by the size
of the image (in this case 256) it gives you the offset within the
image.

Hope this helps,
-- 
Martijn van Oosterhout <kleptog at gmail.com> http://svana.org/kleptog/




More information about the dev mailing list