[OpenLayers-Users] Intercept mouse click using Navigation
control
Colin and Yvonne Law
colinandyvonne at clanlaw.org.uk
Tue Apr 22 04:09:21 EDT 2008
>-----Original Message-----
>From: Eric Lemoine [mailto:eric.c2c at gmail.com]
>Sent: 22 April 2008 08:44
>To: Colin and Yvonne Law
>Cc: users at openlayers.org
>Subject: Re: [OpenLayers-Users] Intercept mouse click using
>Navigation control
>
>On Sun, Apr 20, 2008 at 11:28 PM, Colin and Yvonne Law
><colinandyvonne at clanlaw.org.uk> wrote:
>> Hi
>> A question from a newcomer who doesn't know what he is doing yet.
>> I wish to intercept mouse clicks on the map and found
>examples of how
>> to achieve this using OpenLayers.Control.MouseDefaults in the list
>> archive. I have got this working ok using code of the form:
>>
>> olMouseDefaults = new OpenLayers.Control.MouseDefaults();
>> olMouseDefaults.defaultClick = function(evt) {
>> var point = this.map.getLonLatFromViewPortPx( evt.xy );
>> alert("Got point:" + point);
>> OpenLayers.Event.stop(evt);
>> return false;
>> }
>> map.addControl(olMouseDefaults);
>>
>> Unfortunately I now see from the source of MouseDefaults.js
>that this
>> control is now deprecated and I should be using the Navigation
>> control. I cannot find any examples of how to achieve click
>> interception using this control and my attempts have all failed.
>>
>> Help would be gratefully received.
>
>Hello
>
>You should use OpenLayers 2.6 and its click handler for
>intercepting clicks on the map. See the click-handler.html
>example to understand how to build a control based on that
>click handler.
>
>Cheers,
>--
>Eric
>
Hi Eric
Unfortunately I am actually using UK Ordnanace Survey OpenSpace mapping
system (http://openspace.ordnancesurvey.co.uk) which is based on OpenLayers
2.5. Probably I should just stick with what I have got (which works ok) and
move to the later technique when OpenSpace upgrades.
I had not previously found the examples (though I see now that they are
referenced on the OpenLayers front page). I had been wading through the
documentation which is a trifle heavy going. Even though the examples may
assume the latest version of OpenLayers I can see that they will be very
useful.
Thanks for your help
Colin
More information about the Users
mailing list