Hi all I am trying to get the compass to disappear off my map and have hit a brick wall. Below is my map initialization function and I'm not sure what the variable is. I have tried mapView.compassEnabled == false
, mapView.compassView = nil
and a few other things that I have found to no avail.
I appreciate any help!
@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()
}
Updated answer**
This only works if you have a component that is on top of your map. IF you have just a plain map I would try using negative margins to push the compass out of view.
I found the answer here https://stackoverflow.com/a/57560116/13639051
I added :
mapView.compassViewPosition = .bottomLeft
mapView.compassViewMargins = CGPoint(x: 0, y: 0)
which hides the compass behind a bottom toast that is consistently across the project.