[OpenLayers-Users] Intercept mouse click using Navigation control

Colin and Yvonne Law colinandyvonne at clanlaw.org.uk
Sun Apr 20 17:28:32 EDT 2008


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.

Colin




More information about the Users mailing list