demo (#22) - Problem with controls on map (SelectFeature?, Drawfeature) - OpenLayers?, pgRouting (#258) - Message List
Hi!
First sorry for my poor english :). I don't know even if this topic belongs here but maybe someone have managed with this problem before.
I am having some problem with the OpenLayers? I guess. My application looks like this:
http://img245.imageshack.us/img245/3273/aplikacja.jpg
It provides searching bus stops and bus lines in my city. Also I recently added finding the shortest path using the pgRouting. Before I add finding the shortest path my application worked fine. I chose the bus stop from the select element, like this:
http://img6.imageshack.us/img6/6494/ptrzystanki.jpg
After I choose the bus stops, it appears on the map. When I click it shows the popup with the picture, name and the bus lines like this:
http://img13.imageshack.us/img13/4089/popul.jpg
Everything was fine upon the time I added the pgRouting part. Now the popup menu does not work unless I: - first click on select the start point radiobutton - second click on the navigation radiobutton
When I do this everything is working fine. Without this I click, click and click on the bus stop and the popup menu does not appear!!!! So there must be something wrong with the controls. In my application it looks like this:
- code for popup menu (vector layer):
vector.events.register("featureselected", vector, onFeatureSelect); vector.events.register("featureunselected", vector, onFeatureUnselect); control = new OpenLayers.Control.SelectFeature(vector); map.addControl(control); control.activate();
- code for pgRouting
controls = { start: new OpenLayers.Control.DrawFeature(start, SinglePoint), stop: new OpenLayers.Control.DrawFeature(stop, SinglePoint) } for (var key in controls) { map.addControl(controls[key]); }
- html code for radiobuttons looks like this
<form action="rout.php" method="get"> <input type="radio" name="control" id="noneToggle" value="navigation" onclick="toggleControl(this);" /> <label for="noneToggle">navigate</label><br> <input type="radio" name="control" value="start" id="startToggle" onclick="toggleControl(this);" /> <label for="startToggle">set start point</label><br> <input type="radio" name="control" value="stop" id="stopToggle" onclick="toggleControl(this);" /> <label for="stopToggle">set stop point</label><br> </form>
- the toggleControl() function
function toggleControl(element) { for (key in controls) { if (element.value == key && element.checked) { controls[key].activate(); } else { controls[key].deactivate(); } } }
So I think there is probolem with 'OpenLayers?.Control.SelectFeature?' and 'OpenLayers?.Control.DrawFeature?' I guess. I try to force clicking on 'select start point' and 'navigate' from code like this:
document.getElementById("startToggle").select(); document.getElementById("startToggle").focus(); document.getElementById("startToggle").click(); document.getElementById("noneToggle").select(); document.getElementById("noneToggle").focus(); document.getElementById("noneToggle").click();
But it does not work. Only clicking with mouse does it right. Does anyone please can help me? Maybe someone had similar issue? Please help ...
Regards, Paul
-
Message #934
Hi Paul,
There are probably events not registered the right way (or twice). But even if this problem occurs when you do the routing part, it is 100% OpenLayers? related issue.
I think that you might get much more help on this from OpenLayers? people at their user mailing list. Did you already ask there?
daniel05/07/09 10:23:43 (19 months ago)