我有一个指向许多点数据的geojson链接,我想使用field_1
中的值为某些点着色。
我使用此代码,但不起作用,请不要为这一点着色并保持默认的颜色样式。
知道我错了吗?
var data= new L.GeoJSON.AJAX("url/path/",{
style:function colors(feature) {
switch (feature.properties.field_1){
case 'some value':
return{
color:'#20ff78',
fillOpacity:0.8
};
break;
}
},
onEachFeature:function (feature,layer) {
layer.bindPopup('some text');
}
});
data.addTo(map);
更新
json示例:
{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "MultiPoint", "coordinates": [[15.94, 30.63]]}, "properties": {"f1": 2, "f2": "value", "f3": "other value"}}]}]