Hi GIS-Cracks,
I've been reading in this forum for a while and it helps me lot of times. Now I think it is the time to help me again but maybe other people too. So I try to describe a problem I have with OpenLayers 2.13 dev and the drag feature control.
First of all. I'am working on a bigger GIS-Applikation and the most libraries are bound to this. So I can't change them.
The Problem:
//=>layer for the control was created correctly (controled with firebug)
var dragCtrl = new OpenLayers.Control.DragFeature(editLayer);
app.mapPanel.map.addControl(dragCtrl);
dragCtrl.activate();
//=>if i use console.log at this time I can see the control was created correctly and
//looks like any other drag control on the map
//=>Just for explanation: the record element is from a geoext feature store
var lonlat = record.data.feature.geometry.bounds.getCenterLonLat();
var xy = lonlat.toShortString();
var xyArray = xy.split(', ')
var point = new OpenLayers.Geometry.Point(xyArray[0],xyArray[1]);
var feature = new OpenLayers.Feature.Vector(point);
editLayer.addFeatures(feature);
//=>at this time I expect that it should be possible to drag the added feature on the
//layer
The snippet of code is used in a listener which is executed each time I select a row in a table where some features are stored. So each time there will be a new element of OpenLayers.Control.DragFeature. This is only for testing. Now the strange thing. The first time I call this snippet above I can't drag the feature on the layer. Even if I zoom the map and redraw the layer.
But if I call the code again the new control is added to the map (I have now 2 new dragcontrols at the map => firebug) and a new feature on the layer the drag control works like a charm. For every feature. Also if I call it again and again (new control each time). It doesn't matter where I create the control and where I add it (also if I creates it only one time at the init of the application). If I have only one control on the layer it doesn't work. Each new one works.
Only the first time it fails. What is the problem here?
It is a simple piece of code i think. But I banging my head for it about one week without any solution. I really hope that the solution is simple and I just missed a little detail. Maybe there is anybody out there who had the same problem?!
Thanks for any help. Kalle
