javascript - How to use Leaflet GeoJson Options -
i'm trying implement choropleth of nyc leaflet. i'm following along on it's tutorial doing so, , going fine until reached "adding interaction" section. when try add mouseover function, or other, can't e
defined, , chrome console throws uncaught typeerror: cannot read property 'setstyle' of undefined
error.
this way i've been adding highlightfeature
option oneachfeature
l.geojson(geojsonzipcode, {style: style, oneachfeature: highlightfeature}).addto(map);
these 2 functions being called, style works fine, highlightfeature not:
function style(feature) { return { fillcolor: getcolor(feature.properties.density), weight: 1, opacity: 1, color: 'white', dasharray: '3', fillopacity: 0.7 }; } function highlightfeature(e) { var layer = e.target; layer.setstyle({ weight: 5, color: '#666', dasharray: '', fillopacity: 0.7 }); if (!l.browser.ie && !l.browser.opera) { layer.bringtofront(); } }
under 'adding interaction' section of tutorial you're following, highlightfeature
attached listener hover
events: separate oneachfeature
function this. follow technique in tutorial closely , you'll avoid issue.
Comments
Post a Comment