Lets say I know long/lat of my town. I know how to get mapnik tile for my town on some zoom level. Now…how can I place pushpin on the same tile on lets say my own house long/lat? I need to know exact transformation for long/lat of my house to tile’s pixels? Is there any formula?
In short…how can I find X and Y (in pixels) on the tile using lat/long (in the world)?
Application Im developing is not web application. Im downloading tiles and manipulate with them. Im using .net c#.
When you use this code to get the tile number you are actually doing a projection (transformation) from a lat/lon projection to spherical-mercator flat projection. So you have all the math…
Anyways here you have some python code that does excatly what you want, if you manage to translate something of this into C# then please post it.
I am currently struggling with the same problem. I am working on a robotics control system where one or more robots progress are tracked and displayed on a map. The OpenStreetMap tile system is perfect for this. I can successfully download the tiles stitch them together, scroll, zoom etc.
I am however having difficulty finding the pixel in a tile which represents a specific lat/lon.
I currently have this which I have ported from tangoGPS (www.tangogps.org).
int xpixel = LonToPixel(zoomlevel, ConvertDegreesToRadians(poilon));
int ypixel = LatToPixel(zoomlevel, ConvertDegreesToRadians(poilat));
The Lon values seems ok, however the Lat does not. Did I make a mistake in the porting? Does anyone know of a diffirent source I can look at or some documentation on the formulas?