我正在尝试使用 $.getJSON 函数过滤 geoJSON 数据,但我坚持如何将数据过滤到我想要的内容,然后将其应用于 geojson = 数据。
下面是代码:
// Fetch the GeoJSON file
$.getJSON(config.geojson, function (data) {
geojson = data
features = $.map(geojson.features, function(feature) {
return feature.properties;
});
featureLayer.addData(data);
buildConfig();
要根据特定属性(例如承包商 === 'Tilson'(过滤要素,请对其使用过滤器:
geojson = data.features.filter(function(feature) {
return feature.properties.contractor === 'Tilson';
});