我想在传单中做到这一点!我有一个包含以下数据的GeoJSON文件:
"type": "Feature",
"geometry": {
"type": "MultiPoint",
"coordinates": [
[
-123.77252789,
44.37857221
],
[
-123.77317087,
44.37864694
],
[
-123.77383407,
44.37875853
]
]
},
"properties": {
"title" : "tillicum",
"path_options" : { "color" : "red" },
"time": [
1580403952000,
1580403990000,
1580404202000
],
"speed": [
85,
88,
90
],
"altitude": [
29,
50,
69
],
"heading": [
0,
0,
0
],
"horizontal_accuracy": [
87,
79,
59
],
"vertical_accuracy": [
0,
0,
0
],
"raw": []
},
"bbox": [
[
-124.09386637,
44.34348063
],
[
-124.09386637,
44.56531305
],
[
-123.26148271,
44.56531305
],
[
-123.26148271,
44.34348063
]
]
};
我想获取高度属性,并根据其数值将半径分配给函数中的假设圆:
pointToLayer: function (featureData, latlng) {
return new L.CircleMarker(latlng, result);
}
我只需要知道如何获取这些值并将它们分配给radius。
我正在尝试:
pointToLayer : function(featureData, latlng){
if (featureData.properties.altitude) {
radius = featureData.properties.altitude;
}
return new L.CircleMarker(latlng, featureData.properties.altitude);
}
您必须使用radius属性:
var i = 0;
L.geoJSON(json,{
pointToLayer: function (feature, latlng) {
var marker = L.circleMarker(latlng, {radius: feature.properties.altitude[i]});
i++;
return marker;
}
}).addTo(map);
谢谢,这是我所需要的!