问题
I'm building an image for an Android maps v2 TileOverlay
. Say, for example, that I want a pixel that will end up at a particular latitude and longitude in the tile, to be a particular color. How do I know what latitudes and longitudes in the tile will map to which pixels in my image?
What is the mapping from {latInTile,lngInTile} to {pixelLocationX, pixelLocationY} for a tile?
Thanks.
回答1:
This is exactly what a "projection" is. Google uses the Mercator Projection, described here https://en.wikipedia.org/wiki/Mercator_projection.
The mapping is:
pixelLocationX = longitude
pixelLocationY = ln(tan(latitude/2 + Pi/4))
where longitude and latitude are in radians. Pixel locations then have to be scaled to whatever units you need.
来源:https://stackoverflow.com/questions/15932749/tile-overlay-for-android-maps-v2-how-to-map-latitude-and-longitude-to-a-pixel-l