Using filter function to create a variable with common attribute (Leaflet, GeoJSON, jQuery) -


i have ~70 points associated properties listed in external geojson file. each point has value "year". goal create buttons can click display points given year. example: clicking 2013 button make points "year" = 2013 visible on map.

link project: https://github.com/erinreiss/mallikamap/tree/try3

my attempt 2013 points in single variable, this:

var trees2013_3 = l.geojson(myjson, {filter: year2013get});  function year2013get(feature) {   if (feature.properties.year === "2013") return true } 

then able operate on variable this, trying experiment making button bring 2013 points down opacity .1:

var toggle2013 = document.getelementbyid('button2013');     button2013.onclick = function() {         console.log('show 2013 trees!');         console.log(trees2013_3);         $('trees2013_3').animate({"opacity": .1});     } 

instead, i'm getting error says:

uncaught typeerror: cannot read property 'year' of undefined @ object.year2013get [as filter] (script.js:59) @ e.adddata (leaflet.js:8) @ e.initialize (leaflet.js:8) @ new e (leaflet.js:6) @ object.o.geojson (leaflet.js:8) @ script.js:55

thank you!


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -