简体   繁体   中英

Google Maps Api get lat long dynamically

I want to do something like aerophotography simulator as my university project, using Google Maps Api. For this, I need dynamically change viewport of a map, but for this I have to get lat and long of center of my viewport. Is there any way to do that, using Google Maps Api standart functions?

In order to get the coordinates (LatLng) associated with the center point (x,y) of the MapView you can use the method getCameraPosition() .

(Assuming your GoogleMap object is mMap)

LatLng latLng = mMap.getCameraPosition().target;

In order to animate the camera position use the method animateCamera() , something like this:

mMap.animateCamera(location);

where location is the next location you wish to show on the map ( LatLng object).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM