daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Mar 14th, 2013 15 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function populateMap(e, layerName, icon) {
  2.   var singleMarker;
  3.   finalLayers[layerName] = new L.MarkerClusterGroup();
  4.  
  5.   for(var i = 0; i < e.target.latLngs.length; i++) {
  6.     singleMarker = new L.marker(e.target.latLngs[i], {icon: icon});
  7.     finalLayers[layerName].addLayer(singleMarker);
  8.   }
  9.  
  10.   /* finalLayers[layerName].on('mouseover', function(evt) {
  11.     console.log("mouseover");
  12.     //evt.target.bindPopup('hello').openPopup();
  13.   }); */
  14.  
  15.   finalLayers[layerName].on('clustermouseover', function(evt) {
  16.     console.log("clustermouseover");
  17.     var popup = L.popup();
  18.     var marker = finalLayers[layerName];
  19.  
  20.     marker.setZIndexOffset(1000);
  21.    
  22.     clearTimeout(this.hideTimeout);
  23.    
  24.     this.showTimeout = setTimeout(function () {
  25.       popup.setLatLng(marker.getLatLng());
  26.       map.addLayer(popup);
  27.     }, 200);
  28.   });
  29.  
  30.   finalLayers[layerName].on('clustermouseout', function(evt) {
  31.     var popup = L.popup();
  32.     var marker = finalLayers[layerName];
  33.    
  34.     marker.setZIndexOffset(1000);
  35.    
  36.     clearTimeout(this.showTimeout);
  37.    
  38.     this.hideTimeout = setTimeout(function () {
  39.       map.removeLayer(popup);
  40.     }, 200);
  41.   });
  42.  
  43.   map.addLayer(finalLayers[layerName]);
  44.   fixInitialBounds(e.target.getBounds());
  45. }
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
 
Top