![]() |
火星上的饼干 · Fabric.js ...· 1 年前 · |
![]() |
温暖的西红柿 · spring - springboot ...· 1 年前 · |
![]() |
文武双全的灭火器 · MSBuild 命令行参考 - ...· 2 年前 · |
![]() |
淡定的炒饭 · java - ...· 2 年前 · |
经纬度 顶点坐标 逻辑函数 openlayers |
https://cloud.tencent.com/developer/information/%E6%9C%89%E6%B2%A1%E6%9C%89%E5%8A%9E%E6%B3%95%E5%9C%A8openlayers%E4%B8%AD%E8%8E%B7 |
![]() |
淡定的斑马
4 月前 |
在OpenLayers中,可以通过以下步骤获得修改后的多边形的新坐标:
以下是一个示例代码:
// 创建一个矢量图层
var vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector()
// 创建一个多边形要素并添加到矢量图层中
var polygon = new ol.geom.Polygon([[[-10, 0], [0, 10], [10, 0], [0, -10], [-10, 0]]]);
var feature = new ol.Feature(polygon);
vectorLayer.getSource().addFeature(feature);
// 监听多边形要素的修改事件
feature.getGeometry().on('change', function(event) {
var geometry = event.target;
var coordinates = geometry.getCoordinates();
console.log('新坐标:', coordinates);
// 创建一个地图并添加矢量图层
var map = new ol.Map({
target: 'map',
layers: [vectorLayer],
view: new ol.View({
center: [0, 0],
zoom: 2
});
在上述代码中,我们创建了一个矢量图层,并在其中添加了一个多边形要素。然后,我们监听了多边形要素的修改事件,并在事件回调函数中获取了修改后的新坐标。你可以根据实际需求对新坐标进行进一步处理或应用。
推荐的腾讯云相关产品:腾讯云地图(https://cloud.tencent.com/product/tianditu)