0
マップに新しいマーカーを追加すると、カスタムアイコンを使用できるようにするためのプロパティが追加されます。それからgeoJsonを保存しますが、保存されたgeojsonを見ると、間違った場所に設定されています。Mapboxの更新プロパティがジオメトリになる
これはコードです:
function updtateMarker(t, layer) {
// t is the value I need to save in property "iconSet"
// layer is the layer ID
var marker = featureGroup._layers[layer];
console.log("### updtate Marker ###");
// if marker already exists it works good
if (marker.feature && marker.feature.properties && marker.feature.properties.iconSet) {
marker.feature.properties.iconSet = t;
marker.setIcon(arrayIcon[t]); // update icon on Map
} else {
// Marker is new, it doesn't exist
// update marker icon on Map
marker.setIcon(runnaloIcon[t]);
marker.feature = {properties: {iconSet: t}};
// ***** THIS IS WRONG: why? ******
// this will be saved in "geometry" !??!
}
}
これは番目の間違っにGeoJSONです:
{
"type": "Feature",
"properties": {},
"geometry": {
"properties": {
"iconSet": 2
},
"geometry": {
"type": "Point",
"coordinates": [9.672668, 44.934964]
}
}
これは私が必要なものである:
{
"type": "Feature",
"properties": {
"iconSet": 2
},
"geometry": {
"type": "Point",
"coordinates": [9.672668, 44.934964]
}
}
ちょうど私のコードこれを完了するために、保存部です
var data = featureGroup.toGeoJSON();
var convertedData = JSON.stringify(data);
ありがとうございました!