【发布时间】:2012-03-27 16:27:54
【问题描述】:
我问你是因为我挣扎了几天;我搜索了互联网和stackoverflow,没有找到任何东西。
我需要在地图上精确地放置标记/圆圈/任何东西。 但是,似乎我只能将它们绘制在精确度取决于我所在位置的网格上。因此,他们的位置不够准确。
我正在使用 Wt (C++),但这似乎不是问题的一部分。 我编写的代码绘制了一个 20*20 的圆数组,其坐标是等距的。无论我是在巴黎还是在纽约,我都不会得到相同的结果。
在巴黎: (不能发布图片,因为这是我的第一个问题) http://img818.imageshack.us/img818/7841/parism.png
在纽约: http://img193.imageshack.us/img193/9822/newyorkq.png
在巴黎,我得到了经度的准确度,但没有得到纬度。 在纽约,我无法获得纬度和经度的准确性。
这是我使用的代码:
/*Choose between both*/
double centerLat = 40.714468; double centerLng = -74.005966;//New-York
//double centerLat = 48.854607; double centerLng = 2.347126;//Paris
/*Other parameters*/
double lngMargin = 0.000400;
double latMargin = 0.000400;
int granularity = 20;
int i,j;
WVBoxLayout* layout = new WVBoxLayout();
WColor::WColor myBlue = WColor::WColor(0,0,255,255);
WColor::WColor myRed = WColor::WColor(255,0,0,255);
WColor::WColor myTransparent = WColor::WColor(0,0,0,0);
WGoogleMap::Coordinate coordArray[granularity][granularity];
/* Creating and configuring the map */
WGoogleMap *map = new WGoogleMap(WGoogleMap::Version3);
WGoogleMap::Coordinate centerCoord = WGoogleMap::Coordinate(centerLat,centerLng);
setLayout(layout);
resize(height,width);
map->setCenter(centerCoord,19);
map->setMapTypeControl(WGoogleMap::DefaultControl);
map->enableScrollWheelZoom();
map->addCircle(centerCoord,2,myBlue,2,myTransparent);
/* Here is the loop that draws the circles */
for(i=0 ; i<=granularity-1 ; i++){
for(j=0 ; j<=granularity-1 ; j++){
coordArray[i][j] = WGoogleMap::Coordinate(centerLat + beforeOrAfterTheCenter_Lat * (latMargin/granularity) * i,
centerLng + beforeOrAfterTheCenter_Lng * (lngMargin/granularity) * j);
map->addCircle(coordArray[i][j],1,myRed,2,myTransparent);
}
}
代码应该可以正常工作。您对我可以做些什么来获得更高的准确性有任何线索吗?这是一个众所周知的问题吗?
非常感谢您提供的任何帮助,
L.
【问题讨论】:
-
我的猜测是,投影在纬度、经度上的差异在像素上不相等。尝试在 (Lat, lon) 和 (-Lat, lon) 周围绘制网格,以查看形状是否相似或倒置。也许它在赤道附近有效?
-
Heitor,你是对的。非常感谢你。在 (0,0) 附近,我有一个完美的网格,但我离这一点越远,情况就越糟糕。我将尝试使用 mapCanvasProjectionObject 找出解决方案,并会及时通知您。你认为它可以工作吗?你会尝试别的吗?
-
我相信存在经纬度相等的预测。距离似乎同样遥远。但是,我认为将 Google Maps 投影下的 LatLngs 转换为等距投影中的新 LatLngs 会很棘手。那里可能有公式。我不知道有什么方法可以更改 Google 地图中的投影。
标签: google-maps wt