简体   繁体   English

Google Maps Api动态获取经时

[英]Google Maps Api get lat long dynamically

I want to do something like aerophotography simulator as my university project, using Google Maps Api. 我想使用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? 使用Google Maps Api标准功能有什么办法吗?

In order to get the coordinates (LatLng) associated with the center point (x,y) of the MapView you can use the method getCameraPosition() . 为了获取与MapView的中心点(x,y)关联的坐标(LatLng),可以使用getCameraPosition()方法。

(Assuming your GoogleMap object is mMap) (假设您的GoogleMap对象是mMap)

LatLng latLng = mMap.getCameraPosition().target;

In order to animate the camera position use the method animateCamera() , something like this: 为了使摄影机位置动起来,请使用animateCamera()方法,如下所示:

mMap.animateCamera(location);

where location is the next location you wish to show on the map ( LatLng object). 其中location是您希望在地图上显示的下一个位置( LatLng对象)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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