Android Google Maps Api V2, getting the coordinates for the current map center

怎甘沉沦 提交于 2019-12-05 00:26:27

问题


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.

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


回答1:


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.



来源:https://stackoverflow.com/questions/13980823/android-google-maps-api-v2-getting-the-coordinates-for-the-current-map-center

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!