【问题标题】:LineString to latitude/longitude pairs OpenLayersLineString 到纬度/经度对 OpenLayers
【发布时间】:2020-05-10 14:48:53
【问题描述】:

如何获取给定 LineString 的纬度/经度对集合,这些 LineString 在 OpenLayers 6 中可能是原始格式或压缩格式?

var draw; 
function addInteraction() {
var value ='LineString';
if (value !== 'None') {
draw = new Draw({
  source: source,
  type: 'LineString'
});
map.addInteraction(draw);
  }
}


 addInteraction();

【问题讨论】:

    标签: javascript openlayers openlayers-3 openlayers-5


    【解决方案1】:

    您可以在 drawend 事件中阅读它,如下所示:

    draw.on('drawend', function (e) {
      let format = new ol.format.WKT();
      let wktRepresenation = format.writeGeometry(e.getGeometry(), {
        dataProjection: "EPSG:4326",
        featureProjection: "EPSG:3857",
      });
      console.log(wktRepresenation);
    });
    

    根据需要更改 dataProjection 和 featureProjection。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多