【发布时间】:2019-05-20 21:40:10
【问题描述】:
我必须在 openlayers 地图上绘制一个多边形。这是我的代码:
draw = new Draw({
source: this.vectorSource,
type: 'Polygon'
})
draw.on('drawend', e => {
// sol 1, result is not as required
let coords = e.feature.getGeometry().getCoordinates()
//sol 2, give correct results, but drawn polygon gone
let coords = e..feature.getGeometry().transform('EPSG:3857', 'EPSG:4326').getCoordinates()
}
this.olmap.addInteraction(draw)
我必须将转换后的坐标存储在 DB 中,但解决方案 #2 不能保持绘制多边形的可见性。 在解决方案 #1 的情况下,如果我稍后尝试使用
转换它们,它不会提供所需的格式化坐标 transform(coords, 'EPSG:3857', 'EPSG:4326')
它不返回格式化的坐标。 请指导我在哪里出错以保持多边形的可见性并获取转换后的坐标。
【问题讨论】:
标签: javascript vue.js openlayers openlayers-5