【发布时间】:2020-04-09 21:27:14
【问题描述】:
我有像
这样的字符串POLYGON ((32.5 39.2, 32.6 39.4 .... ))
POINT (32.4 39.2)
使用 Leaflet,React 有没有办法将这些字符串转换为 GeoJSON,例如:
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}
}
在 JavaScript 中?
【问题讨论】:
-
为什么不用正则表达式解析字符串,然后使用
map函数或其他某种迭代器? -
有5种不同的几何类型,如果有库在做,我不会再写代码了=)
标签: javascript leaflet gis geojson