I have a GeoJSON layer with continents info (got it from here), and I want to select a feature(continent) based on its name value or "CONTINENT" in this case. I did some research and ended up with something like this:

var match = featureGroup.eachLayer(function(layer) {
    if (layer.feature.properties.CONTINENT == continentName) {
        return layer

but it doesn't work, because layer doesn't have a feature.

My featureGroup is

$.getJSON("/static/continents.json", function(continents) {
        geojson = L.geoJson(continents, {
        style: style,
        onEachFeature: onEachFeature

Here is a write up of what I did for a class. I used JQUERY as the select tool, and picked states instead of continents.

JQuery AutoComplete Search, In trying to improve my skills in searching, This example reads from the GeoJSON attributes on loading and assigns the state name to the Leaflet internal ID, so when you select a state by searching it fires off a click event that zooms to the state polygon and opens a popup. Write up with a working map link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.