TransWikia.com

Mapbox GL: Possible to move navigation controls?

Geographic Information Systems Asked by Louis-Philippe Tessier on June 13, 2021

Would anyone know if it is possible to move the navigation controls from top-right to top-left? By default, it is top-right, but I would like to add a company’s logo at that position and I’ve seen other Mapbox maps with controls on the left.

3 Answers

Should be possible w/o hacking the DOM:

map.addControl(new mapboxgl.Navigation({position: 'top-left'}));

See the docs.

Note: haven't tried this; as w/ attribution, might be necessary to set the default navigation control to false when initializing the map.

Correct answer by James Conkling on June 13, 2021

I could not get it to work with @james-conkling 's example above. I did this instead:

var nav = new mapboxgl.NavigationControl();
map.addControl(nav, 'top-left');

Answered by max kaplan on June 13, 2021

For the most recent version correct answer is:

map.addControl(new mapboxgl.NavigationControl(), 'top-left');

Answered by Igor Rjabinin on June 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP