mate64 mate64 - 2 years ago 225
Javascript Question

mapbox Pan a Map to Marker and Popup

Is it possible in to pan the map to the marker

regarding the popup

Currently, the popup disappears behind the map's mask. I'm looking for a solution, to fit both into the map, the marker and the popup (like adding some top padding).

featureLayer.on('click', function(e) {
var latLng = e.layer.getLatLng();

mapbox small map with cut popup

Answer Source

I have found a native solution.

You need add the parameter keepInView to the bindPopup() command.

layer.bindPopup('<p>Hello</p>', {keepInView: true});


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download