2

I want center my marker on popup open.. and centering map not in marker latlng, but on center of marker and popup! The problem is that popup has dinamic content(loaded on click).

The map size is full display size in a mobile device! I'm just used autoPanPadding option in popup but not sufficient

Refer to follow picture:

enter image description here

4

SOLUTION:

map.on('popupopen', function(e) {
    var px = map.project(e.popup._latlng);
    px.y -= e.popup._container.clientHeight/2
    map.panTo(map.unproject(px),{animate: true});
});
  • 2
    Could you explain exactly what your code does with comments and accept it as a solution? – GISKid Jun 2 '14 at 18:58
  • There are 3 lines of code is self explanatory – StefanoCudini Jun 2 '14 at 20:54
  • 4
    @StefanoCudini It is always a good gesture to credit the actual author for exactly the same question you have asked elsewhere. – thelastray May 15 '17 at 11:27
  • 2
    @GISKid The actual answer has explanatory comments. – thelastray May 15 '17 at 11:30
  • @thelastray good catch – GISKid May 16 '17 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.