1
我想加載只包含一個多點功能的geoJSON文件的部分到不同的數組中以供在我的OpenLayers應用程序中使用,但我無法正確獲取加載和解析代碼。這是一個語法問題。我GeoJSON的文件中有這樣的結構:加載和解析geojson多點功能到openlayers 3
{
"type": "Feature",
"geometry": {
"type": "MultiPoint",
"coordinates": [
[
243.19,
31.81
],
[
243.05,
31.84
],
...
[
141.3,
38.51
]
]
},
"properties": {
"active": "12 Nov 2005 22:00 - 14 Jul 2006 22:00",
"species": "Bluefin Tuna",
"id": "100508400",
"sex": "unknown"
"time": [
1124432402,
1124434321,
...
1144737900
]
}
}
我試圖加載通過Ajax/JQuery的以GeoJSON和解析多座標到一個數組中,時間座標到一個數組中,並拉出一些屬性值。
var BT100508400Coords = [],
BT100508400Time = [],
id, species;
$.getJSON('data/BT100508400.geojson').done(function (data) {
$(data).each(function() {
BT100508400Coords.push(data.geometry.coordinates);
BT100508400Time.push(data.properties.time);
id = data.properties.id;
species = data.properties.species;
}).done(function() {
makeLineString(id, species, BT100508400Coords, BT100508400Time);
}).fail(function() {
console.log("BT100508400 multipointCoords not populated");
});
});
這種嘗試是接近一個我試圖在這裏:
Creating an array from GeoJSON file in OpenLayers 3
但我已經改變了我的目標位,具體地講,我GeoJSON的文件需要持單多點要素。我似乎無法編寫單一多點特徵的語法,而不是該答案中建議的特徵集合。
非常感謝。
你得到的具體錯誤是什麼? –