在iOS的MapKit中,我们有一个属性,可返回地图坐标的中心。
mapView.centerCoordinate.latitude
mapView.centerCoordinate.longitude
在Google的iOS版Map Sdk中有没有办法做到这一点?
在iOS的MapKit中,我们有一个属性,可返回地图坐标的中心。
mapView.centerCoordinate.latitude
mapView.centerCoordinate.longitude
在Google的iOS版Map Sdk中有没有办法做到这一点?
这里mapView
是GMSMapView
。您需要使用Google地图的projection
属性。
let lat = mapView.projection.coordinate(for: mapView.center).latitude
let lng = mapView.projection.coordinate(for: mapView.center).longitude
print("center Lat & Lng = \(lat),\(lng)")