ios - Mapbox - setCenterCoordinate 正在取消选择注释

标签 ios swift mapbox

我正在试用 mapbox(使用 ios sdk),我遇到了一个问题,我认为我已经缩小了很多范围。这是我的代码:

func centerMap(location: CLLocationCoordinate2D) {
    map.setCenterCoordinate(location,
                            zoomLevel: 14,
                            animated: true)
}

func mapView(mapView: MGLMapView, didDeselectAnnotation annotation: MGLAnnotation) {
    dealDetails.hidden = false
}

func mapView(mapView: MGLMapView, didUpdateUserLocation userLocation: MGLUserLocation?) {
    if let currentLocation = userLocation?.coordinate {
        centerMap(currentLocation)
    }
}

如果我在更新用户位置时没有重新居中 map (即,只是注释掉 centerMap(currentLocation) 调用),那么注释将保持选中状态。重新居中 map 会调用 didDeselectAnnotation 函数,但我不知道如何保持该注释处于选中状态。感谢您的帮助!

最佳答案

如果您更新中心坐标,我认为没有任何解决方法。您必须重新选择注释。但是,您可能不需要这样做。如果您将 map View 上的 userTrackingMode 设置为 .Follow,它应该会自动重新居中。

关于ios - Mapbox - setCenterCoordinate 正在取消选择注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38602164/

相关文章:

android - MapBox android中的标记方向

ios - 如何获取从 UIImagePicker 拍摄的图片的资源 URL

ios - 在我的 ViewController 类中访问函数内部的 Swift 字典变量时出现问题

ios - 如何在 Scene Kit 中对同一场景使用多个摄像头

ios - WKWebview, imagePicker 在选择图片时不显示完成按钮

java - 在 MapBox View 上平移/缩放时如何阻止 ScrollView 滚动?

ios - Mapbox NavigationController 不显示路线

ios - 加载非 http ://url scheme 后的操作

ios - 如何关闭 Storyboard 弹出框

ios - 如何持久存储 twitter iOS5 帐户以用于多个 View Controller