someOptions1 is only showing on map even if (feature.properties && feature.properties['WORK_NAME'].includes('ABCD')) condition is getting matched. All feature.properties['WORK_NAME'] is displaying on console log but if condition is not getting matched and so someOptions2 style is not showing.
const someOptions1 = {
fillColor: "yellow",
fillOpacity: 0.15,
opacity: 0.45,
color: "green",
weight: 3,
};
const someOptions2 = {
fillColor: "red",
fillOpacity: 0.15,
opacity: 0.45,
color: "black",
weight: 3,
};
function getStyle(feature) {
//console.log(feature.properties['WORK_NAME']);
//if (feature.properties && feature.properties['WORK_NAME'].toLowerCase() === 'ABCD'.toLowerCase()) {
if (feature.properties && feature.properties['WORK_NAME'].includes('ABCD')) {
console.log("Matched");
return someOptions2;
}
return someOptions1;
}
var geo1 = L.geoJson({features:[]},{onEachFeature:function popUp(f,l){
var out = [];
if (f.properties){
for(var key in f.properties){
out.push(key+": "+f.properties[key]);
}
l.bindPopup(out.join("<br />"));
}
},style: getStyle}).addTo(map);
var wfunc = function(base,cb){
importScripts('leaflet/shapefile/shp.js');
shp(base).then(cb);
}
var worker = cw({data:wfunc},2);
worker.data(cw.makeUrl('proposal.zip')).then(function(data){
geo1.addData(data)
//geo.bringToBack();
},function(a){console.log(a)});
Hi Dear
I have been using this plugin from quite some time and everything was working fine. But now I required different color polygon if feature.properties['WORK_NAME'] is ABCD. Kindly help please.
someOptions1 is only showing on map even if (feature.properties && feature.properties['WORK_NAME'].includes('ABCD')) condition is getting matched. All feature.properties['WORK_NAME'] is displaying on console log but if condition is not getting matched and so someOptions2 style is not showing.