[OpenLayers-Users] getLonLatFromPixel in IE

Frank Broniewski brfr at metrico.lu
Tue May 25 07:17:43 EDT 2010


Hi,

I use
map = new OpenLayers.Map(map_div);
...
map.events.register("click", map, showCoords);

where showCoords the function for display is. Alternatively see 
http://dev.openlayers.org/releases/OpenLayers-2.9.1/examples/events.html 
for an alternate example


Frank


> <html>
> <head>
> <title>OpenLayers Demo</title>
> <style type="text/css">
>        html, body, #basicMap {
>            width: 400px;
>            height: 300px;
>            margin: 0;
>        }
> </style>
> <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
> <script
> src='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>'></script>
> <script>
>        function init() {
>          map = new OpenLayers.Map("basicMap");
>          var gphy = new OpenLayers.Layer.Google(
> "Google Physical",
>                  {type: G_PHYSICAL_MAP}
>              );
>
>          map.addLayer(gphy);
>          map.zoomToMaxExtent();
>
> OpenLayers.Event.observe($('basicMap'),"click",showCoords.bindAsEventListener(map));
>        }
>
>        function showCoords(e)
>        {
>         var LL = this.getLonLatFromPixel (e.xy);
>           window.alert(LL);
>        }
> </script>
> </head>
> <body onload="init();">
> <div id="basicMap"></div>
> </body>
> </html>
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users


-- 
Frank BRONIEWSKI

METRICO s.à r.l.
géomètres
technologies d'information géographique
rue des Romains 36
L-5433 NIEDERDONVEN

tél.: +352 26 74 94 - 28
fax.: +352 26 74 94 99
http://www.metrico.lu



More information about the Users mailing list