美文网首页
高德地图设置中心

高德地图设置中心

作者: 稀释1 | 来源:发表于2021-12-10 14:09 被阅读0次
       let TipsSearch = AMapPOIKeywordsSearchRequest()
        TipsSearch.keywords = "西安市"
//        search.aMapPOIKeywordsSearch(TipsSearch)
func onPOISearchDone(_ request: AMapPOISearchBaseRequest!, response: AMapPOISearchResponse!) {
        if response.count == 0 {
            return
        }
        for (_, item) in response.pois.enumerated() {
            if item.name == "西安市" {
                mapView.centerCoordinate = CLLocationCoordinate2D(latitude: CLLocationDegrees(item.location.latitude), longitude: CLLocationDegrees(item.location.longitude))

                latitude = item.location.latitude
                longitude = item.location.longitude
                mapView.setZoomLevel(zoomLevel, animated: false)
                break
            }
        }
    }

相关文章

网友评论

      本文标题:高德地图设置中心

      本文链接:https://www.haomeiwen.com/subject/rjpcfrtx.html