// JavaScript Document
// define view - center map
map_alle_hikes.setView(new L.LatLng(34.5, -120), 3);
map_alle_hikes.addLayer(osm);
var promise = $.getJSON("_geoJSON/usa_hiking_database_alle_hikes.min.geojson");
var markers = L.markerClusterGroup({
showCoverageOnHover: false
});
promise.then(function(data) {
// Add markers
var ushike = L.geoJson(data, {
pointToLayer: function(feature, latlng) {
switch (feature.properties.icon) {
case 'easy': return L.marker(latlng, {icon: easyIcon}).bindPopup("" + feature.properties.Name + '
'+ feature.properties.description);
case 'moderate': return L.marker(latlng, {icon: moderateIcon}).bindPopup("" + feature.properties.Name + '
'+ feature.properties.description);
case 'strenuous': return L.marker(latlng, {icon: strenuousIcon}).bindPopup("" + feature.properties.Name + '
'+ feature.properties.description);
default: return L.marker(latlng);
}
}
});
// Cluster
markers.addLayer(ushike);
map_alle_hikes.addLayer(markers);
});