I need a way of getting the center Longitude of the current Google Map screen. I'm not dealing with any City scale but being able to scroll around the Atlantic and Western Pacific areas of the globe and being able to get a good enough center Longitude. And it needs to be reasonably updated as you scroll around.
This is on Android with Windows. I'm using the Android v2 API.
I have menu buttons that will take me to certain locations. And if you scroll all around after you go there, the calculated center Longitude usually stays the same but sometimes it does vary some.
On every dispatchDraw() I've tried using these operations to try to get the updated center Longitude:
They work once you go to that location, but if you scroll all around it tends to return the same initial value.
projection = googleMap.getProjection();
LatLng tCenterLatLng =
projection.getVisibleRegion().latLngBounds.getCenter();
dCenterLongitude = tCenterLatLng.longitude;
CameraPosition cameraPosition = googleMap.getCameraPosition();
if ( cameraPosition != null )
{
LatLng viewCenter = cameraPosition.target;
Log.d(TAG, "viewCenter: "+viewCenter.longitude);
}
And I've also tried various OnCameraChangeListener, OnMapClickListener and OnCameraMoveListener and most only return a value once or twice.
Is there any other way to get anything from information about your scrolling? Or any lower level View information, because the above isn't working well enough.
UPDATE: With the code I have, I think it'll work good enough where the longitude does change some. I think that dispatchDraw() is being called so fast that the value doesn't seem to change much, but it does a little.
Thanks!