I have a GeoJSON map. It's a map of a country, which is made up of states, which are in turn made up of sub-state regions.
I can create a Leaflet map where I can highlight (in this case 'orange') the sub-state regions as the cursor touches them. I would like to simultaneously highlight other sub-state regions (in a different colour) that are in the same state as the initial region (ie. I want to highlight the selected sub-state region one colour, and the remainder of the state another colour).
I think I need to put the new bit of code at the comment 'new bit of code here', but I don't know how to select the other elements in the geojson that ARE NOT the one currently selected, but that still have the feature property STATE_NAME16 == tmp
.
geojson = L.geoJson(States_Data, {
onEachFeature: function (feature, layer) {
layer.on('mouseover', function () {
var tmp = feature.properties.STATE_NAME16 ;
this.setStyle({
'fillColor': 'orange'
});
//[new bit of code here]
});
}
}).addTo(map);