首页 > 解决方案 > 获取MKMapView中心的经纬度

问题描述

我希望当用户单击地图中心存在的按钮时,地图被锁定并且我得到地图的纬度和经度,实际上得到地图的中心我不想使用谷歌地图或 Mapbox 我想使用地图套件

标签: swiftmapkitmkmapview

解决方案


试试下面的代码:

@IBAction func aaa(_ sender: UIButton) {
    print(self.mapView.centerCoordinate.latitude)
    print(self.mapView.centerCoordinate.longitude)
}

推荐阅读