Created
October 1, 2015 08:31
-
-
Save FranckErnewein/60e420d99ec1d7aa55d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var L = window.L; | |
var addressPoints = window.addressPoints; | |
var tiles = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { | |
maxZoom: 18, | |
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors, Points © 2012 LINZ' | |
}), | |
latlng = L.latLng(-37.82, 175.24); | |
var map = L.map('map', { | |
center: latlng, | |
zoom: 13, | |
layers: [tiles] | |
}); | |
console.log(L.DivIcon.prototype); | |
var markers = L.markerClusterGroup({ | |
iconCreateFunction: function createMarker(cluster) { | |
var markers = cluster.getAllChildMarkers(); | |
var title = ''; | |
for (var i = 0; i < markers.length; i++) { | |
title += markers[i].options.data[2] + ','; | |
} | |
return new L.DivIcon({ | |
html: '<div class="marker">' + title + '</div>' | |
}); | |
} | |
}); | |
var CustomMarker = L.Marker.extend({ | |
options: { | |
data: {} | |
} | |
}); | |
function loop(i) { | |
var a = addressPoints[i]; | |
var title = a[2]; | |
var marker = new CustomMarker(new L.LatLng(a[0], a[1]), { | |
title: title, | |
data: a | |
}); | |
marker.bindPopup(title); | |
markers.addLayer(marker); | |
if (addressPoints[i]) { | |
setTimeout(function() { | |
loop(i + 1); | |
}, 300); | |
} | |
} | |
loop(0); | |
map.addLayer(markers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment