Small popup on mouseover and a bigger one for click on marker

31 views
Skip to first unread message

Hajo

unread,
Jun 11, 2016, 3:59:59 PM6/11/16
to Leaflet
I'd like to display a summary popup when hover over a marker and close it when leaving the marker.
When clicking on ta marker, I want to display a details popup, which should stay open until clicking again or hover over another marker.

Here is my code, which does not work. It does nothing on click.
          // Tooltip on mouse over
          marker.on('mouseover click', function(event) {
            if (event.type == "mouseover") {
              console.log("mouseover");
              marker.bindPopup(
              feature.properties.name, {'offset': L.point(0,-15)}).openPopup();
            } else if (event.type == "click") {
              console.log("click");
              cliquer();
              marker.bindPopup(
              feature.properties.name + '<br/>' + feature.properties.desc + '<br/>'  + latlng + 'Additional Information,
              {'offset': L.point(0,-15)}).openPopup();
            };
          });
          marker.on('mouseout', function(){marker.closePopup();});
          return marker;

Vic Slagter

unread,
Jun 12, 2016, 3:57:16 PM6/12/16
to Leaflet
You can have only one popups open. Maybe try with mouseout event in place of mouseover?

Hajo

unread,
Jun 12, 2016, 4:01:07 PM6/12/16
to Leaflet
One at a time is ok.

The small one when mouse is on the marker and when clicking, this one should close and and bigger one with more details should open and stay open until the next click...
Reply all
Reply to author
Forward
0 new messages