Fun*_*bby 5 openlayers openlayers-5
我正在尝试升级到 OpenLayers v5.2.0,但我看不到有一条清晰的路径可以将圆绘制为多边形(我需要它,以便我可以将其存储在我们的数据库中)
这就是我正在做的...
if (webMapValues.activeDrawControl == "Circle") {
var wgs84Sphere = new ol.Sphere(6378138);
webMapValues.drawObj = new ol.interaction.Draw({
features: webMapValues.features,
type: /** @type {ol.geom.GeometryType} */ (webMapValues.drawType),
geometryFunction: function (coordinates, geometry) {
if (!geometry) {
geometry = new ol.geom.Polygon(null);
}
var center = coordinates[0];
var last = coordinates[1];
var dx = center[0] - last[0];
var dy = center[1] - last[1];
var radius = Math.sqrt(dx * dx + dy * dy);
var circle = ol.geom.Polygon.circular(wgs84Sphere, ol.proj.toLonLat(center), radius);
circle.transform('EPSG:4326', 'EPSG:3857');
geometry.setCoordinates(circle.getCoordinates());
return geometry;
}
});
}
Run Code Online (Sandbox Code Playgroud)
...但是 ol.Sphere 甚至不是这个版本的 OpenLayers 中的东西,而这个版本的 OpenLayers 中的 ol.sphere 不喜欢这样...
任何帮助是极大的赞赏!!
| 归档时间: |
|
| 查看次数: |
1663 次 |
| 最近记录: |