Daniel Espina
Daniel Espina

Reputation: 674

How do I move the logo/watermark and the info button on MGLMapView?

I'm wondering how do I move Mapbox's logo and the info button up a little on the map view. But anything I do doesn't seem to affect the map

enter image description here

--my first attempt to solve the problem

    let mapboxLogo = mapView.logoView
    mapView.logoView.isHidden = true
    let logoLeftConstraint = NSLayoutConstraint(item: mapboxLogo, attribute: NSLayoutAttribute.leading, relatedBy: .equal, toItem: mapView, attribute: NSLayoutAttribute.leading, multiplier: 1.0, constant: 8)
    let logoBottomConstraint = NSLayoutConstraint(item: mapboxLogo, attribute: NSLayoutAttribute.bottom, relatedBy: .equal, toItem: mapView, attribute: NSLayoutAttribute.bottom, multiplier: 1.0, constant: 32)

    mapboxLogo.translatesAutoresizingMaskIntoConstraints = false
    mapView.addConstraints([logoLeftConstraint, logoBottomConstraint])

    mapView.addSubview(mapboxLogo)

The result: enter image description here

Upvotes: 1

Views: 1358

Answers (1)

jmkiley
jmkiley

Reputation: 976

If you are on Mapbox Maps SDK for iOS v3.7.0, you should be able to do this by a couple of ways:

  1. Save the attribution button's action sheet. Then remove the original wordmark and attribution button, and place a new wordmark and attribution button in the desired location. Add the action sheet to the new attribution button.
  2. Remove the original constraints and add your own.

You can find more suggestions and sample code here.

Upvotes: 1

Related Questions