高德地图设置中心

2021-12-10  本文已影响0人  稀释1
       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
            }
        }
    }
上一篇 下一篇

猜你喜欢

热点阅读