[OpenLayers-Users] combining drag and select layers on one map - drag not working

Eric Lemoine eric.lemoine at camptocamp.com
Mon Apr 6 02:22:35 EDT 2009


Hi

As you've noticed, since recently, you can have a select feature
control work with multiple vector layers. Yet, Andreas or others will
correct me if I'm wrong, your use case isn't covered - you cannot have
a drag control, working on one layer, and a select control working, on
another layer, activated at the same time. Only the layer(s) of the
control activated last will be interactive.

Eric

2009/4/4, Charlie DeTar <chazen at gmail.com>:
> Hi,
>
> I'm trying to construct a map that contains a draggable marker in
> addition to features that, when clicked, produce a popup.  Reading the
> docs and examples, it seemed that the way to do this is to use a vector
> layer with a DragFeature control, and an additional vector layer with a
> SelectFeature control to handle popups.  However, I'm finding that once
> the SelectFeature control has been activated, the DragFeature no longer
> works -- dragging only pans the map.  I'm testing this using Firefox 3.0
> under Linux with stable OpenLayers (2.7).
>
> I've been trying to figure out if this has something to do with event
> propagation, and have tried setting stopUp and stopDown to false for
> both the dragFeature and selectFeature handlers to no effect.  Calling
> dragFeature.handlers.feature.moveLayerToTop() makes the drag handler
> work, but kills the selectFeature, regardless of what order the layers
> are added.  Though I would like both layers working simultaneously, I
> did find that disabling the selectable layer using the LayerSwitcher
> made the drag control work again in stable 2.7, but in the latest SVN
> R9190 dragging still doesn't work after disabling the selectable layer.
>
> Any suggestions for how I might be able to get a draggable layer and
> separate popup-producing layer working simultaneously on one map?
>
> Here are routines I'm using to construct the layers:
>
> var map;
> function init() {
>     map = new OpenLayers.Map('map');
>     map.addControl(new OpenLayers.Control.LayerSwitcher());
>     map.addLayer(
>        new OpenLayers.Layer.WMS("OpenLayers WMS",
>             "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} )
>     );
>
>     map.setCenter(new OpenLayers.Geometry.Point(0, 0), 4);
>
>     add_draggable();
>     add_selectable();
> }
> function add_draggable() {
>     var draggable = new OpenLayers.Layer.Vector(
>             "Draggable",
>             {
>                 styleMap: new OpenLayers.StyleMap({
>                     externalGraphic:
>                         "http://openlayers.org/dev/img/marker-gold.png",
>                     pointRadius: 10
>                 }),
>             }
>     );
>     map.addLayer(draggable)
>     draggable.addFeatures([
>         new OpenLayers.Feature.Vector(
>            new OpenLayers.Geometry.Point(0, 0)
>         )
>     ]);
>
>     var dragFeature = new OpenLayers.Control.DragFeature(draggable);
>     map.addControl(dragFeature);
>     dragFeature.activate();
> }
> function add_selectable() {
>     var selectable = new OpenLayers.Layer.Vector("Selectable");
>     selectable.addFeatures([
>         new OpenLayers.Feature.Vector(
>              new OpenLayers.Geometry.Point(5, 5)),
>         new OpenLayers.Feature.Vector(
>              new OpenLayers.Geometry.Point(-5, -5)),
>     ]);
>     map.addLayer(selectable);
>
>     var selectControl = new
>          OpenLayers.Control.SelectFeature(selectable);
>     map.addControl(selectControl);
>     selectControl.activate();
> }
>
> cheers,
> Charlie
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>

-- 
Envoyé avec mon mobile

Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Users mailing list