Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function populateMap(e, layerName, icon) {
- var singleMarker;
- finalLayers[layerName] = new L.MarkerClusterGroup();
- for(var i = 0; i < e.target.latLngs.length; i++) {
- singleMarker = new L.marker(e.target.latLngs[i], {icon: icon});
- finalLayers[layerName].addLayer(singleMarker);
- }
- /* finalLayers[layerName].on('mouseover', function(evt) {
- console.log("mouseover");
- //evt.target.bindPopup('hello').openPopup();
- }); */
- finalLayers[layerName].on('clustermouseover', function(evt) {
- console.log("clustermouseover");
- var popup = L.popup();
- var marker = finalLayers[layerName];
- marker.setZIndexOffset(1000);
- clearTimeout(this.hideTimeout);
- this.showTimeout = setTimeout(function () {
- popup.setLatLng(marker.getLatLng());
- map.addLayer(popup);
- }, 200);
- });
- finalLayers[layerName].on('clustermouseout', function(evt) {
- var popup = L.popup();
- var marker = finalLayers[layerName];
- marker.setZIndexOffset(1000);
- clearTimeout(this.showTimeout);
- this.hideTimeout = setTimeout(function () {
- map.removeLayer(popup);
- }, 200);
- });
- map.addLayer(finalLayers[layerName]);
- fixInitialBounds(e.target.getBounds());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement