<div class="gmail_quote">
2010/5/25 Frank Broniewski <span dir="ltr"><<a href="mailto:brfr@metrico.lu">brfr@metrico.lu</a>></span><br>Hi,<br>
<br>well obviously you can't pass any arguments to an event function
(in IE). The function only has access to window.event. You can do<br>
<br>
function coords(event) {<br>
var xy = event.object.<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">getLonLatFromViewPortPx(event.xy);<br>
var x = xy.lon;<br>
var y = xy.lat;<br>
...<br>
}</blockquote><br><br>Thank you Frank, that did it, works both with Firefox and IE.<br><br>Note though that the listener has to be registered the way you indicated, not how I had tried initially. Full code below.<br><br>
Thanks,<br><br>Luís<br><br><html><br> <head><br> <title>OpenLayers Demo</title><br> <style type="text/css"><br> html, body, #basicMap {<br> width: 400px;<br> height: 300px;<br>
margin: 0;<br> }<br> </style><br> <!--<script src="<a href="http://www.openlayers.org/api/OpenLayers.js">http://www.openlayers.org/api/OpenLayers.js</a>"></script>--><br>
<script src="../openlayers/OpenLayers.js"></script><br> <script src='<a href="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ">http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ</a>'></script><br>
<script><br> function init() {<br> map = new OpenLayers.Map("basicMap");<br> var gphy = new OpenLayers.Layer.Google(<br> "Google Physical",<br> {type: G_PHYSICAL_MAP}<br>
); <br> map.addLayer(gphy);<br> map.zoomToMaxExtent();<br> map.events.register("click", map, showCoords);<br> }<br> <br> function showCoords(e)<br> {<br>
var xy = e.object.getLonLatFromViewPortPx(e.xy);<br> window.alert(xy.lon + " " + xy.lat);<br> }<br> </script><br> </head><br> <body onload="init();"><br> <div id="basicMap"></div><br>
</body><br></html><br></div>