Mapbox Swift 罗盘可见性属性

问题描述

大家好,我正试图让指南针从我的地图上消失并撞到砖墙。下面是我的地图初始化函数,我不确定变量是什么。我尝试了 mapView.compassEnabled == falsemapView.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()
  }

解决方法

更新答案**

这仅适用于地图顶部的组件。如果您只有一张普通地图,我会尝试使用负边距将指南针推出视野。

我在这里找到了答案https://stackoverflow.com/a/57560116/13639051

我加了:

mapView.compassViewPosition = .bottomLeft

mapView.compassViewMargins = CGPoint(x: 0,y: 0)

将指南针隐藏在贯穿整个项目的底部吐司后面。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...