Search code examples
leafletmarkergeojson

How find marker in geojson?


I have geojson layer like this:

          var icon_mfc = L.icon({
                iconUrl: 'icons/mfc_h32.png',
                iconAnchor: [11, 32]
          });
          var mfc_layer = L.geoJson(mfc,{
                        pointToLayer: function (feature, latlng) {
                               return L.marker(latlng, {icon: icon_mfc}).bindPopup(feature.properties.name);
                        }
          });

i want find marker and i want fitbound and open popup on this marker, i know(for example) attribute marker "feature.properties.name".


Solution

  • Use the .eachLayer method to iterate through layers, and write your JavaScript logic inside of it.