javascript - Can't get featureLayer.setStyle to remove highlight on mouseout (mapbox/leaflet) -


so, i'm building map of water taking permits in toronto. work in progress available here: http://pennybeames.net/maps/permitsto.html

i'm using l.mapbox.featurelayer add markers:

var permitslayer = l.mapbox.featurelayer(permits,  {       pointtolayer: function (feature, latlng) {       return l.circlemarker(latlng, permitsstyle(feature));}      }).addto(map); 

i've got custom info control leaflet choropleth example working (http://leafletjs.com/examples/choropleth.html).

i change style , update info in custom control follows:

featurelayer.eachlayer(function (layer) {         layer.on('mousemove', function (e) {             // highlight feature                 layer.setstyle({                     weight: 2,                     opacity: 1,                     fillopacity: 0.9                 });                  //update properties in domutil                 info.update(layer.feature.properties);         });    });    

all working smoothly until mouseout. info control updates fine (either switching properties of new target or reverting empty state), style won't change. highlight stays on.

featurelayer.eachlayer(function (layer) {         layer.on('mouseout', function (e) {                   //reset style                   featurelayer.setstyle(permitsstyle);                    //empty properties in domutil                   info.update();          });    });   

i don't errors, don't see change. i've tried

featurelayer.resetstyle(e.target) 

but uncaught typeerror: featurelayer.resetstyle not function.

there simple question, it's eluding me. insight, hivemind?

don't bind events inside eachlayer loop, featurelayer.on('myevent',function(e) {e.layer.setstyle(my_new_style)})


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -