Javascript 如何获取个人价值观的传单;在GeoJSON中?
我想在传单上这样做! 我有一个包含以下数据的GeoJSON文件:Javascript 如何获取个人价值观的传单;在GeoJSON中?,javascript,function,get,leaflet,geojson,Javascript,Function,Get,Leaflet,Geojson,我想在传单上这样做! 我有一个包含以下数据的GeoJSON文件: "type": "Feature", "geometry": { "type": "MultiPoint", "coordinates": [ [ -123.77252789, 44.37857221 ], [ -123.77317087, 44.37864694 ], [ -123.77383407, 44.37875853 ] ] }
"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);
}
我只需要知道如何获取这些值并将它们指定给半径
我正在尝试:
pointToLayer : function(featureData, latlng){
if (featureData.properties.altitude) {
radius = featureData.properties.altitude;
}
return new L.CircleMarker(latlng, featureData.properties.altitude);
}
必须使用“半径”属性:
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);
我建议您看看lodash。它有一些非常方便的函数,可以帮助您操作对象和数组,并结合地图和过滤器功能,我认为您可以得到您想要的。目前我找不到我正在寻找的解决方案!