适用于Android地图v2的图块叠加层:如何将纬度和经度映射到像素位置 [英] Tile Overlay for Android maps v2: How to map latitude and longitude to a pixel location

查看:72
本文介绍了适用于Android地图v2的图块叠加层:如何将纬度和经度映射到像素位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Android Maps v2 TileOverlay构建图像.举例来说,假设我希望某个像素会以一种特定的颜色出现,该像素最终会在图块中以特定的纬度和经度结束.我怎么知道图块中的哪些经度和纬度将映射到图像中的哪些像素?

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?

图块从{latInTile,lngInTile}到{pixelLocationX,pixelLocationY}的映射是什么?

What is the mapping from {latInTile,lngInTile} to {pixelLocationX, pixelLocationY} for a tile?

谢谢.

推荐答案

这正是投影"的含义. Google使用墨卡托投影,如 https://en.wikipedia.org/wiki/Mercator_projection 所述

This is exactly what a "projection" is. Google uses the Mercator Projection, described here https://en.wikipedia.org/wiki/Mercator_projection.

映射为:

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.

这篇关于适用于Android地图v2的图块叠加层:如何将纬度和经度映射到像素位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆