Mapbox Swift 罗盘可见性 属性
Mapbox Swift compass visibilty property
大家好,我正试图让指南针从我的地图上消失,结果撞到了一堵砖墙。下面是我的地图初始化函数,我不确定变量是什么。我尝试了 mapView.compassEnabled == false
、mapView.compassView = nil
和其他一些我发现无济于事的方法。
感谢任何帮助!
@objc func initMap() {
if mapView != nil {
print("Attempting to init map that is already initialized, returning")
return
}
mapView = NavigationMapView(frame: UIApplication.shared.delegate!.window!!.bounds, // TODO: Set frame from react
styleURL: NSURL(string: "mapbox://styles/paway/ckcp7w04x03by1iqi1t26uilu") as URL?)
guard let mapView = self.mapView else { return }
mapView.zoomLevel = 2
mapView.delegate = self
mapView.locationManager.setDistanceFilter?(6)
PWLocationManager.shared.delegate = self
mapView.setCenter(CLLocationCoordinate2D(latitude: 37.0902, longitude: -95.7129), animated: false)
mapView.navigationMapViewDelegate = self
switch cameraMode {
case "overview":
mapCameraState = .overviewMode
mapView.userTrackingMode = .followWithHeading
case "followHeading":
mapCameraState = .followMode
mapView.userTrackingMode = .followWithHeading
default:
mapView.userTrackingMode = .none
}
mapView.isPitchEnabled = true
mapView.showsUserLocation = true
self.addSubview(mapView)
addMapTapRecognizer()
addObservers()
}
更新答案**
这仅在您的地图顶部有一个组件时才有效。如果你只有一张普通地图,我会尝试使用负边距将指南针推到视线之外。
我在这里找到了答案
我补充说:
mapView.compassViewPosition = .bottomLeft
mapView.compassViewMargins = CGPoint(x: 0, y: 0)
将指南针隐藏在整个项目始终如一的底部吐司后面。
大家好,我正试图让指南针从我的地图上消失,结果撞到了一堵砖墙。下面是我的地图初始化函数,我不确定变量是什么。我尝试了 mapView.compassEnabled == false
、mapView.compassView = nil
和其他一些我发现无济于事的方法。
感谢任何帮助!
@objc func initMap() {
if mapView != nil {
print("Attempting to init map that is already initialized, returning")
return
}
mapView = NavigationMapView(frame: UIApplication.shared.delegate!.window!!.bounds, // TODO: Set frame from react
styleURL: NSURL(string: "mapbox://styles/paway/ckcp7w04x03by1iqi1t26uilu") as URL?)
guard let mapView = self.mapView else { return }
mapView.zoomLevel = 2
mapView.delegate = self
mapView.locationManager.setDistanceFilter?(6)
PWLocationManager.shared.delegate = self
mapView.setCenter(CLLocationCoordinate2D(latitude: 37.0902, longitude: -95.7129), animated: false)
mapView.navigationMapViewDelegate = self
switch cameraMode {
case "overview":
mapCameraState = .overviewMode
mapView.userTrackingMode = .followWithHeading
case "followHeading":
mapCameraState = .followMode
mapView.userTrackingMode = .followWithHeading
default:
mapView.userTrackingMode = .none
}
mapView.isPitchEnabled = true
mapView.showsUserLocation = true
self.addSubview(mapView)
addMapTapRecognizer()
addObservers()
}
更新答案**
这仅在您的地图顶部有一个组件时才有效。如果你只有一张普通地图,我会尝试使用负边距将指南针推到视线之外。
我在这里找到了答案
我补充说:
mapView.compassViewPosition = .bottomLeft
mapView.compassViewMargins = CGPoint(x: 0, y: 0)
将指南针隐藏在整个项目始终如一的底部吐司后面。