0
votes

I have a mapbox project that I need to be able to re-center the map when a popup closes. Right now, clicking a marker will pan the map and after the user closes the popup they are left with the map panned over to the new location. I simply need the map to recenter to the original location I set as my map center.

I've not found a method using the mapbox api so I don't have any code to start. I'm more looking for someone who might have experience with such a configuration.

1

1 Answers

1
votes

Since mapbox.js is built on top of leaflet you can use the Leaflet API.

You can listen for popupclose events. Then you can call map.setView() and center the map at the original position.

Here is a working example