0
let marker = L.marker(new L.LatLng(lat, lon), { icon: markerIcon });
map.addLayer(marker);

Just like the normal marker, how can we use enablePermanentHighlight() on features of FeatureLayer. Any alternative?

This is how I use this on marker,

marker.enablePermanentHighlight();

or

marker.options.highlight = "permanent";

I have used the same method on feature layer, but that layer was not highlighting/blinking.

foundFeatureLayer.eachActiveFeature((layer) => {
    if (layer.feature || layer instanceof L.Marker) {
        layer.enablePermanentHighlight();
    }
});
john gravois
  • 392
  • 2
  • 8
Usama Saleem
  • 424
  • 2
  • 4
  • 16
  • I'm not familiar with `enablePermanentHighlight` function in Leaflet core. Can you please link to the documentation on this function? – GavinR Jul 11 '18 at 14:47
  • Its a package, I want to know anything similar to [this](https://github.com/brandonxiang/leaflet.marker.highlight) – Usama Saleem Jul 11 '18 at 15:05

1 Answers1

1

you need to wait for your featureLayer to load before you can loop through individual features.

fl.on("load", function (e) {
  fl.eachActiveFeature((layer) => {
    if (layer.feature || layer instanceof L.Marker) {
        layer.enablePermanentHighlight();
    }
  });
});

http://jsbin.com/nuxawek/edit?html,output

john gravois
  • 392
  • 2
  • 8