I'm making a cloropleth map with geoJSON and Leaflet. Right now each year has a separate geoJSON file and I load each of them as below:
function loadGeoJSON(data) { var json = null; $.ajax({ async: false, global: false, url: data, dataType: "json", success: function (data) { json = data; } }); return json; } var ccc2 = loadGeoJSON("t2015.geojson"); var t2015 = L.geoJson(ccc2, { style: style, onEachFeature: onEachFeature }); map.addLayer(t2015); var ccc3 = loadGeoJSON("t2014.geojson"); var t2014 = L.geoJson(ccc3, { style: style, onEachFeature: onEachFeature }); The geoJSON are of countries and are the same each year. I would like to combine the geoJson files into one with each feature having the attributes: 2014_1, 2014_2, 2014_3, 2015_1, 2015_2, 2015_3 etc. Is it possible to load one file with all years and break it into variables which only has the attributes from a single year (i.e. 2014_1, 2014_2, 2014_3) so they can be separate layers on the map?
أكثر...
function loadGeoJSON(data) { var json = null; $.ajax({ async: false, global: false, url: data, dataType: "json", success: function (data) { json = data; } }); return json; } var ccc2 = loadGeoJSON("t2015.geojson"); var t2015 = L.geoJson(ccc2, { style: style, onEachFeature: onEachFeature }); map.addLayer(t2015); var ccc3 = loadGeoJSON("t2014.geojson"); var t2014 = L.geoJson(ccc3, { style: style, onEachFeature: onEachFeature }); The geoJSON are of countries and are the same each year. I would like to combine the geoJson files into one with each feature having the attributes: 2014_1, 2014_2, 2014_3, 2015_1, 2015_2, 2015_3 etc. Is it possible to load one file with all years and break it into variables which only has the attributes from a single year (i.e. 2014_1, 2014_2, 2014_3) so they can be separate layers on the map?
أكثر...