美文网首页
leaflet要素图层转wkt

leaflet要素图层转wkt

作者: 嘀灬学生卡 | 来源:发表于2021-07-23 16:43 被阅读0次

关键词:leaflet; WKT; terraformer-wkt-parser

将leaflet L.polyline、L.polygon类型的图层转换为wkt格式。
1.引入插件
import WKT from "terraformer-wkt-parser"
2.示例
let latlngs = [
  [ // first polygon
    [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring
    [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole
  ],
  [ // second polygon
    [[41, -111.03],[45, -111.04],[45, -104.05],[41, -104.05]]
  ]
];
let layer= L.polygon(latlngs, {color: 'red'});
let wktString = WKT.convert(layer.toGeoJSON().geometry);
console.log(wktString);

相关文章

网友评论

      本文标题:leaflet要素图层转wkt

      本文链接:https://www.haomeiwen.com/subject/melpmltx.html