我有一个LatLng对象,我想把它的坐标移到东边500米处.我找不到内置的方法.我见过
https://gis.stackexchange.com/a/2964,但实际上我的结果太不准确(约15%).如何精确换米?
注意:我不是在寻找移动谷歌地图相机,我知道如何做到这一点.
我试过了:
static final double KILOMETERS_PER_DEGREE = 111.111;
static LatLng offsetLongitude(LatLng initialCoords, float horizontalOffsetInMeters){
double degreeOffset = 1.0 / KILOMETERS_PER_DEGREE * horizontalOffsetInMeters / 1000.0;
double longitudeOffset = Math.cos(initialCoords.latitude * Math.PI / 180.0) * degreeOffset;
return new LatLng(initialCoords.latitude, initialCoords.longitude + longitudeOffset);
}
public static LatLngBounds boundsForSpanWidth(LatLng midpoint, float targetSpanWidth){
LatLng east = offsetLongitude(midpoint, -targetSpanWidth);
LatLng west = offsetLongitude(midpoint, targetSpanWidth);
LatLngBounds newBounds = new LatLngBounds(west, east);
return newBounds;
}
然而,当我用一个目标跨度为5000米的点(不靠近杆或任何东西)称它时,我得到两个相距约6170米的点.为什么?