【发布时间】:2015-03-27 01:25:51
【问题描述】:
我有一个谷歌地图。我在上面放置了一个 tileOverlay(一个虚构的游戏世界)。游戏使用 x,y 坐标系。我需要将我所有的 lat lng 坐标转换为这个精确的 x,y 系统。
我在地图上选择了两个点,并从游戏中获得了它们的真实 xy 值。 然后从 android 地图中得到这两个点的 lat lng。 然后使用此代码:
// First spot data
static Double game_1_x = 1972.606;
static Double game_1_y = 3817.044;
static Double map_1_lng = 42.108797;
static Double map_1_lat = 43.152977;
// second spot data
static Double game_2_x = -1154.11;
static Double game_2_y = -2715.203;
static Double map_2_lng = -48.3334;
static Double map_2_lat = -80.346344;
Double LAT = latFromMarker;
Double LON = lngFromMarker;
// this works
// all markers added with this equation fall on the correct longitude line
Double X = game_1_x + (LON - map_1_lng) * (game_1_x - game_2_x) / (map_1_lng - map_2_lng);
// this does not work
// markers added using this equation are always too far north or south of where they need to be
Double Y = game_1_y + (LAT - map_1_lat) * (game_1_y - game_2_y) / (map_1_lat - map_2_lat);
“y”转换无法正常工作的原因是由于 Google Maps API v2 墨卡托投影,纬度线的间距不相等。
我需要知道我需要做些什么来解释这种波动。我确信有一些高级方程式或其他东西,但我已经毫不费力地用谷歌搜索了几个小时,却空手而归。
【问题讨论】:
标签: android google-maps google-maps-api-2