1
IHAVE以下代码:给定一个GeoJSON文件,如何仅在Leaflet中显示特征质心?
$.getJSON("rodents.geojson",function(data){
var rodents = L.geoJson(data,{
pointToLayer : function(feature,latlng){
var marker = L.marker(latlng);
//turf.centroid(feature).geometry.coordinates
// marker.bindPopup(feature.properties.Location + '<br/>' + feature.properties.OPEN_DT);
return marker;
}
});
});
事实上,我想通过这种方法计算的质心通过的经纬度变量:turf.centroid(feature).geometry.coordinates
PointToLayer需要特征和经纬度作为参数,所以我怎样才能实现这?我尝试了很多东西,但没有奏效。