[OpenLayers-Users] Handler problems

Tom (JDi Solutions) tom.dean at jdi-solutions.co.uk
Fri Aug 31 10:20:58 EDT 2007


Hi all,

I've been creating a handler based on the code here:
http://trac.openlayers.org/wiki/Handlers

What's supposed to happen is that the user clicks on the map and the
co-ordinates are sent off to a web service which returns a polygon in WKT
which is then plotted.  That all works fine except that after the user has
clicked the map once the next click anywhere in the map window will result
in a further call to the web service and no response from any other control
they may have clicked on, e.g. a link or button.  If the click was outside
the map div the user is then able to click on any other controls on the
page.  If the click was in the map window the behaviour continues.

In the code below I can comment out everything in the sendpoint function so
that it does nothing but the behaviour still persists, i.e. the next click
will not activate anything else within the browser window.

What's even more strange is that this actually works perfectly well in IE6
and this behaviour is observed in Firefox only which tells me I'm doing
something very wrong.  Firebug is not reporting any errors.  I've not tried
IE7 or other browser as yet.

Any ideas anyone?

Here's some code:

            drawControls = {
                toidselect: new OpenLayers.Control()
            };

            OpenLayers.Util.extend(drawControls['toidselect'], {

                draw: function () {
                    this.point = new OpenLayers.Handler.Point(
drawControls['toidselect'],
                        {"done": this.sendpoint})
                    this.point.activate();
                },


                sendpoint: function (point) {
                    var xpoint = point.lon;
                    var ypoint = point.lat;
                    if(!xpoint) {
                        xpoint = point.x;
                        ypoint = point.y;
                    }

                    xmlhttp.open('get', 'polyselect.php?coords=' + xpoint +
',' + ypoint, true);
                    xmlhttp.onreadystatechange = drawTOIDPolygon;
                    xmlhttp.send(null);
                }
            });

            for(var key in drawControls) {
                map.addControl(drawControls[key]);
            }

Thanks in advance,

Tom Dean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070831/c1a8c577/attachment.html


More information about the Users mailing list