Ios 如何在MGL mapView中进行缩放,使视图包含一个;“对象”;在地图上
我在mapbox地图上有一条MGLPolyline,当用户点击它围绕线的中心线并尽可能放大以显示完整的线时,我希望这样做。目前,我使定心工作正常,但缩放随机工作: 我只是将其设置为最大缩放,然而,这当然不是我想要的 下面是我要添加缩放量的地方:Ios 如何在MGL mapView中进行缩放,使视图包含一个;“对象”;在地图上,ios,swift,zooming,mapbox,Ios,Swift,Zooming,Mapbox,我在mapbox地图上有一条MGLPolyline,当用户点击它围绕线的中心线并尽可能放大以显示完整的线时,我希望这样做。目前,我使定心工作正常,但缩放随机工作: 我只是将其设置为最大缩放,然而,这当然不是我想要的 下面是我要添加缩放量的地方: func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation) { print("Tapped") mapView.setCen
func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation) {
print("Tapped")
mapView.setCenter(CLLocationCoordinate2D(latitude: annotation.coordinate.latitude, longitude: annotation.coordinate.longitude), zoomLevel: mapView.zoomLevel, animated: true)
mapView.deselectAnnotation(annotation, animated: false)
}
MGLMapView
实际上有一个专门用于此目的的烘焙方法。您应该能够使用实现该功能。如果您想在多段线周围摆弄填充,还可以使用该方法的风格
如下所示:
func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation) {
mapView.showAnnotations(pointAnnotations, animated: true)
}
MGLMapView
实际上有一个专门用于此目的的烘焙方法。您应该能够使用实现该功能。如果您想在多段线周围摆弄填充,还可以使用该方法的风格
如下所示:
func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation) {
mapView.showAnnotations(pointAnnotations, animated: true)
}
是否已将
MGLPolyline
作为或添加到地图视图中?根据您共享的代码片段,您似乎使用了注释
,但我只想确认。correct@riastrada您是否已将MGLPolyline
作为或添加到地图视图中?根据您共享的代码片段,看起来您使用了注释
,但我只想确认一下。correct@ria您可以显示代码吗?由于标签暗示我正在使用swiftHey,因此我在这里还有一个问题:。我不想在这里添加thsi,因为我觉得太晚了。你能显示代码吗?由于标签暗示我正在使用swiftHey,因此我在这里还有一个问题:。我不想在这里添加thsi,因为我觉得它太不相关了