问题
I would like to do this in the Leaflet! I have a GeoJSON file with these data:
"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
]
]
};
I would like to take the altitude properties and, based on their numerical value, assign the radius to a hypothetical circle in the function:
pointToLayer: function (featureData, latlng) {
return new L.CircleMarker(latlng, result);
}
I would only need to know how to take these values and assign them to radius.
i'm trying with:
pointToLayer : function(featureData, latlng){
if (featureData.properties.altitude) {
radius = featureData.properties.altitude;
}
return new L.CircleMarker(latlng, featureData.properties.altitude);
}
回答1:
You have to use the radius property:
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);
https://jsfiddle.net/falkedesign/dkheswg1/
来源:https://stackoverflow.com/questions/60031554/leaflet-how-to-take-individual-values-in-geojson