How to parse geoJson file into Leaflet layers -


i'm interested in different symbology different geojson features, based on criteria available in geojson file. know can accomplish oneachfeature hook, want user have layer control (layer display on/off) on parsed layers. create layergroup. i'm js , leaflet novice , having trouble figuring out how individual feature geojson file added layergroup.

some of code:

var active = new l.layergroup(); var inactive = new l.layergroup();  // kcdfp_parcel geojson file variable ( var i=0; < kcdfp_parcel.features.length; ++i )     if (kcdfp_parcel.features[i].properties.inactive == 0){  // inactive=no // how add active layergroup???? var overlays = {     "active": active,     "inactive": inactive}; l.control.layers(overlays).addto(map); 

the advantage of oneachfeature gives direct access layer created feature.

also, if using new keyword, you have capitalize name of "class". easier not use new:

var active = l.layergroup(); var inactive = l.layergroup();  l.geojson(kcdfp_parcel, {     oneachfeature: function(feature, layer) {         if (feature.properties.inactive == 0) {             layer.addto(active);         } else {             layer.addto(inactive);         }     }  })  // rest had var overlays = {     "active": active,     "inactive": inactive }; l.control.layers(overlays).addto(map); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -