Reputation: 481
I try to find code to drag a polygon (not modify)....OL3
polygon is created by code (bbox for print area).
can anybody shere code?
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);
Upvotes: 4
Views: 2184
Reputation: 1312
This extension called Transform Interaction work fine with dragging. It also has support for rotating, stretching and scaling. It is definitely worth a look!
Upvotes: 1
Reputation: 2126
See the drag features example here: http://openlayers.org/en/v3.4.0/examples/drag-features.html
Also there is work in progress on a Translate interaction see: https://github.com/openlayers/ol3/pull/3250
Upvotes: 3