【发布时间】:2021-09-03 23:43:55
【问题描述】:
我从数据库中获得了一个 JSON,但现在我需要将其转换为 GeoJson 以在我的地图中使用它
我找到了这个解决方案,但它显示了一个未定义的数组。
$.getJSON("./origin/neworigin.json", function(jsonData) {
var outGeoJson = {}
outGeoJson['properties'] = jsonData
outGeoJson['type']= "Feature"
outGeoJson['geometry']= {"type": "Point", "coordinates":
[jsonData['latitude'], jsonData['longitude']]}
console.log(outGeoJson)
});
这是来自 myJSON 的示例
[{"station":"BORJA","institution":"SENCICO","longitude":"-77.0064","latitude":"-12.0855"},
{"station":"SCARQ","institution":"SENCICO","longitude":"-71.5408","latitude":"-16.385"},
{"station":"SCAR2","institution":"SENCICO","longitude":"-71.5364","latitude":"-16.3934"},...
【问题讨论】:
标签: javascript json maps geojson