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的文件需要持单多点要素。我似乎无法编写单一多点特征的语法,而不是该答案中建议的特征集合。
非常感谢。
你得到的具体错误是什么? –