【发布时间】:2015-07-27 19:23:41
【问题描述】:
我想知道是否可以在mapKit中为MKLocalSearchRequest和MKLocalSearchResponse设置一个国家?
在我的地图视图中,用户可以搜索 zip/state。但我不想在其他国家展示热门歌曲,因为在这里没有任何意义。
提前致谢,
localSearchRequest = MKLocalSearchRequest()
localSearchRequest.naturalLanguageQuery = "23138"
localSearch = MKLocalSearch(request: localSearchRequest)
localSearch.startWithCompletionHandler { (localSearchResponse, error) -> Void in
if localSearchResponse == nil || self.mapView == nil{
var alert = UIAlertView(title: nil, message: "Place not found", delegate: self, cancelButtonTitle: "Try again")
alert.show()
return
} else {
let location = CLLocationCoordinate2D(latitude: localSearchResponse.boundingRegion.center.latitude, longitude: localSearchResponse.boundingRegion.center.longitude)
let span = MKCoordinateSpanMake(0.05, 0.05)
let region = MKCoordinateRegion(center: location, span: span)
self.mapView.setRegion(region, animated: false)
self.pointAnnotation = MKPointAnnotation()
self.pointAnnotation.coordinate = location
self.mapView.addAnnotation(self.pointAnnotation)
}
}
【问题讨论】:
标签: ios objective-c iphone xcode swift