Leaflet map – Zoom and click color on certain states only

I am using leaflet for a map of the usa to show available properties in each state, I would like to remove zoom and clicked color on the states that do not have properties available.

This is my code:

function zoomToFeature(e) {

var prevLayerClicked = null;

function onEachFeature(feature, layer) {
//mouseover: highlightFeature,
//mouseout: resetHighlight,
click: function(e){
if (prevLayerClicked !== null) {
// Reset style
weight: 2,
opacity: 1,
color: ‘white’,
dashArray: ”,
fillOpacity: 1.9,
fillColor: getColor(feature.properties.availability)});


var layer = e.target;

weight: 1,
color: ‘#fff’,
dashArray: ”,
fillOpacity: 0.9,
fillColor: ‘red’

if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {

prevLayerClicked = layer;

I know i will have to change the function onEachFeature, but do not know how to do this. This is my first map project so any help would be great!

Here is the link to my map: https://www.thekeithcorp.com/interactive-map/

Read more here:: Leaflet map – Zoom and click color on certain states only

Leave a Reply

Your email address will not be published. Required fields are marked *