[OpenLayers-Users] DragFeature - how to prevent dragging of features??

Roald de Wit roald.dewit at lisasoft.com
Sat Apr 25 00:32:05 EDT 2009


Hi Plen,

In OpenLayers 2.8 you will be able to select features on multiple 
layers! So, the easiest option for you is to have 2 layers, one with a 
drag control and the other without and a selectFeature control that 
handles both layers.
For an example how to select features on multiple layers, see [1].

Btw: 2.8 has not been released yet, but you can use the release 
candidate directly: [2] or download: [3]

Regards, Roald

[1] http://openlayers.org/dev/examples/select-feature-multilayer.html
[2] http://openlayers.org/api/2.8-rc1/OpenLayers.js
[3] http://openlayers.org/download/OpenLayers-2.8-rc1.zip

plen wrote:
> Hello,
>
> I am using the drawing controls from OpenLayers 2.5 and am using the "drag"
> control:
>
> drag: new OpenLayers.Control.DragFeature(getFeaturesLayer())
>
> I put all of my features (points, lines, polygons) in the layer that the
> drag control is looking at.  There are some features, however, which I do
> not want the user to actually be able to drag and am looking for a way to
> prevent the drag control from dragging it.  I am putting the features which
> I don't want to drag into the same layer as the features that I do want to
> drag because I also use the "select" control on that same layer.  If I were
> to separate the draggable and non-draggable features into separate layers, I
> will not be able to activate the "select" control and be able to select
> features in both layers.
>
> So, the question is, can a feature that is added to a layer that the drag
> control is looking at somehow have a "do not drag" flag?
>
> Thanks for any thoughts - Peter
>   




More information about the Users mailing list