Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same style is showing even if the condition is matched #211

Open
himsashu opened this issue Jun 4, 2024 · 0 comments
Open

Same style is showing even if the condition is matched #211

himsashu opened this issue Jun 4, 2024 · 0 comments

Comments

@himsashu
Copy link

himsashu commented Jun 4, 2024

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.

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("
"));
}
},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)});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant