6

I have create my map with Leaflet exactly how I want it (with my markers and externals links).

I would like to have the popup always fixes in the top right hand corner (for an example).

Is there any way to fix the popup's location ?

0

2 Answers 2

9

You could for example use a div-Container and a click-Event instead of the default popups:

HTML:

<div id="info"></div>

Javascript:

onEachFeature: function (feature, layer) {
        //layer.bindPopup(feature.properties.name);

        layer.on('click', function (e) {
            document.getElementById("info").innerHTML = feature.properties.name;
        });
    }

http://jsfiddle.net/expedio/z1nw3pt4/

1
  • Since it is not attached to the marker, what function do we use to keep it open (t.i, remove the fade in and out attribute)? And How to close with click elsewhere so it behaves just like a regular marker popup? Commented Mar 8, 2019 at 15:59
3

I had the same problem and didn't find a clear solution in forums. I resolved this problem with help of extra pane (http://leafletjs.com/reference-1.3.0.html#map-pane)

https://codepen.io/Yudash/pen/XEEwWv

I see it is not actual now but maybe it will save someone's time.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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