SHARE
TWEET

Untitled

a guest Jun 25th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // load geojson data with default variables shown
  2. var mapLayer = L.geoJSON(data[0]['features'], {
  3.     pointToLayer: function (feature, latlng) {
  4.         var marker = L.marker(latlng, {icon: defaultMarker});
  5.         return marker;
  6.     },
  7.     onEachFeature: onEachFeature
  8. }).addTo(map);
  9.  
  10. // on each marker, do the following
  11. function onEachFeature(feature,layer) {
  12.     layer.bindTooltip(feature.properties.label);
  13.     layer.on('mouseover', function(e){
  14.         layer.setIcon(highlightMarker);
  15.         layer.openTooltip();
  16.     });
  17.     layer.on('mouseout', function(e){
  18.         console.log("mouseout");
  19.         layer.setIcon(defaultMarker);
  20.         layer.closeTooltip();
  21.     });
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top