mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

Move compass view [iOS]

Open afomich opened this issue 9 years ago • 7 comments

Hello, is there possible to move compass view to another place?

afomich avatar Feb 09 '17 14:02 afomich

This seems to be a duplicate of #8003 The first option in https://github.com/mapbox/mapbox-gl-native/issues/8003#issuecomment-278644190 is not a possible fix for this issue, however, the second option would work.

Closing in favor of #8003

frederoni avatar Feb 09 '17 14:02 frederoni

I've actually found a nifty solution to adjust the top constraint in Swift 3.0.

    // var get set so that compass doesn't get change upon re-layout
    private var compassOriginY: CGFloat = 44

    override func updateConstraints() {
        super.updateConstraints()

        // Get constrait for the top edge
        for constraint in self.constraints where constraint.firstItem as? NSObject == self.compassView {

            constraint.constant = compassOriginY
        }
    }

Amazingly, you can access the trailing constraint (x axis) by changing constraint.firstItem to .secondItem too!

mqln avatar Jun 14 '17 19:06 mqln

you should override viewDidLayoutSubviews() method and reset location for compassView ex:

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    var centerPoint = self.mapView.compassView.center
    centerPoint.y += compassOriginY
    self.mapView.compassView.center = centerPoint
}

benphamx avatar Jul 21 '17 05:07 benphamx

How can I move the compass in Android?

SantoshDhirwani avatar May 29 '19 09:05 SantoshDhirwani

How can I change compassView bounds ?

gregoireLem avatar Oct 14 '20 15:10 gregoireLem

Is it just me, or did this stop working? Fine for a long time for me, but now it wants to move the compass back to the default position.

Tapestes avatar Mar 03 '21 21:03 Tapestes

@Tapestes same for me

gregoireLem avatar Mar 19 '21 15:03 gregoireLem