Tile Overlay for Android maps v2: How to map latitude and longitude to a pixel location

烂漫一生 提交于 2019-12-10 12:04:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!