拖动要素 POLYGON OL3

Drag a feature POLYGON OL3

我试图找到拖动多边形的代码(不是修改)....OL3

多边形由代码创建(打印区域的 bbox)。

任何人都可以在这里编码吗?

    var format = new ol.format.WKT();
    var feature = format.readFeature(wkt2);

    selectInteraction = new ol.interaction.Select({style: styles});
    map.addInteraction(selectInteraction);
    selectInteraction.getFeatures().push(feature);
    modifyInteraction = new ol.interaction.DragAndDrop({
        features: selectInteraction.getFeatures()
    });
    map.addInteraction(modifyInteraction);


    vector = new ol.layer.Vector({ 
        style: styles,
        source: new ol.source.Vector({
            features: [feature]
        })
    });
    map.getLayers().insertAt(1000, vector);

在此处查看拖动功能示例:http://openlayers.org/en/v3.4.0/examples/drag-features.html

翻译交互也正在进行中,请参阅:https://github.com/openlayers/ol3/pull/3250

这个名为 Transform Interaction 的扩展可以很好地拖动。它还支持旋转、拉伸和缩放。绝对值得一看!