【发布时间】:2020-11-13 10:05:00
【问题描述】:
我给地图一个组成多边形的四个坐标:
var x_1 = 28.0244307;
var y_1 = -25.8635238;
var x_2 = 28.0244307;
var y_2 = -25.8835238;
var x_3 = 28.0444307;
var y_3 = -25.8835238;
var x_4 = 28.0444307;
var y_4 = -25.8635238;
所以当我启用功能以便修改现有多边形时,修改后的多边形显然应该有新的坐标,我怎样才能得到修改后的多边形的新坐标?
var coords = [
[x_1, y_1],
[x_2, y_2],
[x_3, y_3],
[x_4, y_4],
[x_1, y_1]
];
var polygon = new ol.geom.Polygon([coords]);
var feature = new ol.Feature(polygon);
polygon.transform('EPSG:4326', 'EPSG:3857');
var vectorSource = this.vectorSource;
vectorSource.addFeature(feature);
var select = new ol.interaction.Select();
var modify = new ol.interaction.Modify({
features: select.getFeatures(),
});
var snap = new ol.interaction.Snap({
source: vectorSource,
});
this.map.addInteraction(select);
this.map.addInteraction(modify);
this.map.addInteraction(snap);
【问题讨论】:
标签: openlayers openlayers-3 openlayers-5