谷歌Android地图API V2,得到的坐标为当前地图中心地图、坐标、中心、谷歌

2023-09-05 07:04:03 作者:心有困兽

我使用谷歌Android地图API V2(不图形页面或MapActivity),我有困难得到的坐标为地图中央。

我想用

  @覆盖
公共无效onCameraChange(CameraPosition为arg0){
    // TODO自动生成方法存根
    地理codeCenter(/ * Location对象* /);
}
 

但我不能从CameraPosition对象获取的纬度/长。该相机还具有更多的维度,你可以看看地图,在不同的音高,现在也一样,所以得到的纬度中心/经度是不一样的,因为用户不能保证在看从鸟瞰地图,除非某些手势被禁用。

有没有更好的方式来做到这一点?我不希望用户必须长时间点击一个标记,以将其拖动地图的时候,我希望他们只知道地图的中心是围绕平移的用户。

map.getMyLocation()方法是别的东西,像目前LocationProvider位置。也不看似选项,尽管事实上,我现在用的GPS,它仍然返回null

解决方案   

但我无法得到纬度/经度从CameraPosition对象

的target公共数据成员一个 CameraPosition 经纬度的地图中心,根据我读的文档。

I am using Android Google Maps Api V2 (not MapView or MapActivity) and I am having difficulty getting the coordinates for the center of the map.

Android应用版谷歌地图室内精确定位系统

I was thinking of using

@Override
public void onCameraChange(CameraPosition arg0) {
    // TODO Auto-generated method stub
    geoCodeCenter(/*Location object*/);
}

but I can't get the lat/long from the CameraPosition object. the camera also has more dimensions as you can look at the map at different pitches now too, so getting the center of for latitude/longitude isn't the same since the user isn't guaranteed to be looking at the map from birds eye view, unless certain gestures are disabled.

Is there a better way to do this? I don't want the user to have to long click a marker to drag it around the map, I want them to just know where the center of the map is by the user panning it around.

the map.getMyLocation() method is for something else, like the current LocationProvider position. Also not seemingly the option, notwithstanding the fact that I am using GPS and it still returns null

解决方案

but I can't get the lat/long from the CameraPosition object

The target public data member on a CameraPosition is a LatLng of the map center, based upon my reading of the docs.