[OpenLayers-Users] Dragable markers

Andreas Hocevar ahocevar at opengeo.org
Mon Jul 6 13:53:04 EDT 2009


On Mon, Jul 6, 2009 at 7:25 PM, Admin
TrouveTonGull.info<contact at trouvetongull.info> wrote:
>
>>> I try to make
>>>
>>> new OpenLayers.Control.DragFeature(name_layer1, name_layer2),
>>>
>>> with my layers but no change :( It's a bad syntax?
>>>
>>
>> 1) Control.DragFeature only supports one layer
>> 2) You have to pass the layer object, not the layer name. This
>> requires of course that your layer is created before you create the
>> control.
>>
>
> I have many layers so, i put the principal? new
> OpenLayers.Control.DragFeature(OpenLayers.Layer.OSM.Mapnik),  not work
> :( what is the layer object?

Layer.OSM.Mapnik is a tiled layer, there are no features on it.
Features are on vector layers (OpenLayers.Layer.Vector,
OpenLayers.Layer.GML, OpenLayers.Layer.WFS).

If you have a line in your code like:

var layer = new OpenLayers.Layer.Vector("my vector layer");

then you can configure your DragFeature control with

var dragfeature = new OpenLayers.Control.DragFeature(layer);

Maybe I should have said "instance" instead of "object", then things
would have been clearer in the first place.

Regards,
Andreas.


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list