Hi,
I have a large geojson containg points ("origin");
I want to filter markers, based on properties.TIPOLOGIA (values ranging from 1 to 4) and create different layers for each type.
var map = L.map('map').setView([42.413, 12.846], 7);
//aggiungo un layer di sfondo, o Base Layer var baseLayer = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{ attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http:// mapbox.com">Mapbox</a>', maxZoom: 18 }).addTo(map);
// Dati GeoJSON var nidi = L.geoJson(origin, { pointToLayer : function (feature, latlng) { lat = feature.geometry.coordinates[0]; lng = feature.geometry.coordinates[1]; return L.marker([lng,lat]).bindPopup(feature.properties.DATA+ '<br/>' + feature.properties.ESPOSIZIONE); } }); //Crea markers var markers = new L.MarkerClusterGroup(); markers.addLayer(nidi); //... Add more layers ... //map.addLayer(markers); // zomm sui nidi inseriti map.fitBounds(nidi.getBounds(), { padding: [50, 50] }); // Creo due oggetti con i riferimenti rispettivamente ai BaseLayers ed ai FeatureLayers var baseMaps={ "Sfondo OSM": baseLayer, }; var featureLayers={ "nidi": markers,
}; // Creo i controlli L.control.layers(null, featureLayers,{collapsed:false}).addTo(map); // Per un metodo moolto più succinto (che usa però Mapbox.js) guardare questo link: https://www.mapbox.com/mapbox.js/example/v1.0.0/toggle-baslayers/
If yyou know how to do that starting from origin.shp it' even better.
THANKS