我很难弄清楚如何在用户点击指向当前位置的注释时显示注释标题。除此以外一切正常。我正在使用来自 https://github.com/varshylmobile/LocationManager 的 CLLocationManager
包装器但我认为它不会影响 Mapbox
,因为我可以在 map 上正确显示我的图钉。
这是截图示例:
如您所见,我可以毫无问题地运行该应用程序。只是当我为图钉设置一些注释标题和副标题,并在运行时点击它时,它没有显示任何内容。
这是我的注释代码片段:
let point = MGLPointAnnotation()
point.coordinate = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
point.title = "Hello world!"
point.subtitle = "Welcome to The Ellipse."
self.mapView.addAnnotation(point)
let point2 = MGLPointAnnotation()
point2.coordinate = CLLocationCoordinate2D(latitude: 37.43259552, longitude: location.coordinate.longitude)
point2.title = "Hello world!"
point2.subtitle = "Welcome to The Ellipse."
self.mapView.addAnnotation(point2)
self.mapView.selectAnnotation(point, animated: true)
self.mapView.showAnnotations([point, point2], animated: true)
这里是调用函数:
func mapView(mapView: MGLMapView, annotationCanShowCallout annotation: MGLAnnotation) -> Bool {
return true
}
func mapView(mapView: MGLMapView, imageForAnnotation annotation: MGLAnnotation) -> MGLAnnotationImage? {
return nil
}
我在 iOS 9.2、xCode 7 上。
谢谢!
最佳答案
实例化 map View 后我忘记了这行代码。
mapView.delegate = self
谢谢!
关于ios - Mapbox iOS SDK 3 - 点击注释时不显示注释标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34829369/