In Google Maps for Android v1, MapView had a convenience method: getMapCenter()
. Now I cannot figure out how to get map center with v2 of this api. I have perused the API documentation, but there is no mention of such a feature. Please advise.
Thanks, Igor
It takes pixels as an integer value to pad the left, top, right, and bottom edges. It would be called as follows: map.setPadding(400, 100, 100, 0); Copy. This means that 400 pixels are padded in the left corner and 100 pixels are padded in the top and right corners.
Long press the marker to enable dragging. When you take your finger off the screen, the marker will remain in that position. Markers are not draggable by default. You must explicitly set the marker to be draggable either with MarkerOptions.
I had the same problem. It seems you can get the center this way:
mMap.getCameraPosition().target
where mMap is the GoogleMap instance from your activity. This will return a LatLng object which basically represents the center of the map.
Note that the GeoPoint
class is not available anymore.
According to http://developer.android.com/reference/com/google/android/gms/maps/model/CameraPosition.html
target is "The location that the camera is pointing at." (I tested it with the sample code and it worked okay for me)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With