Hi James,
You could try to replace both the SelectFeature and DragFeature
controls by a ModifyFeature control, which contains a SelectFeature
control itself so you could listen to its "featureselected" event to
display your popup. Dragging the marker while it's selected should work.
Regards,
Alexandre
On 10-09-29 04:43 PM, James Humphreys wrote:
Hi,
I'd like to have markers on the map that have a baloon appear when I
click them, and are also draggable. I've created an OpenLayers map
with markers using a vector layer. When I click on the markers I'd
like a baloon to pop up (a FramedCloud). That's easy enough - I added
a SelectFeature control which, when clicked, add a FramedCloud to the
map. Secondly, I'd like those markers to be draggable, so I added a
DragFeature control to the vector layer.
It look like those two Controls can't co-exist. If I add them both,
the SelectFeature control doesn't work.
I've put a quick example up at
http://www.humphreys.be/james/selectanddrag/selectanddrag.html
Here I've activated both features, so only "drag" works. You can
download the selectanddrag.HTML and selectanddrag.JS file to your PC,
modify and play with them. If you switch off the dragFeature, the
selectControl works fine.
I saw this has been discussed before, back in Feb:
http://osgeo-org.1803224.n2.nabble.com/Click-on-OpenLayers-Feature-Vector-td4631284.html
According to this post the two Controls simply aren't compatible.
Has the situation changed? Does anyone know how I can create a marker
that can have a bubble appear when I click it AND is draggable?
I'd love to hear anyone's opinion on this before I delve head first
into writing my own custom control (and I'm not that great at
Javascript so it could take a while...)
Thanks,
James
Here's a code snippet:
map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
map.addLayer(layer);
placesVL = new OpenLayers.Layer.Vector("My places", {... });
map.addLayer(placesVL);
var marker1 = new OpenLayers.Feature.Vector(getPoint(-0.58, 51.8));
var marker2 = new OpenLayers.Feature.Vector(getPoint(-0.53, 51.2));
placesVL.addFeatures([marker1, marker2]);
selectControl = new OpenLayers.Control.SelectFeature(placesVL,
{onSelect: onFeatureSelect, onUnselect:
onFeatureUnselect});
map.addControl(selectControl);
selectControl.activate();
var dragFeature = new OpenLayers.Control.DragFeature(placesVL,
{'onComplete': onDragPlaceComplete});
map.addControl(dragFeature);
dragFeature.activate();
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users