[OpenLayers-Trac] [OpenLayers] #2990: MousePosition Control returns 2, 2 at upper left corner of the map

OpenLayers trac-20090302 at openlayers.org
Tue Dec 28 11:57:01 EST 2010


#2990: MousePosition Control returns 2,2 at upper left corner of the map
---------------------+------------------------------------------------------
 Reporter:  sanojr   |       Owner:              
     Type:  bug      |      Status:  new         
 Priority:  minor    |   Milestone:  2.11 Release
Component:  general  |     Version:  2.10        
 Keywords:           |       State:              
---------------------+------------------------------------------------------
 Hi,

 I am trying to use the OpenStreetMap and was trying to locate the pixel
 location on the map using lat and lon but was returning me incorrect
 values. Later i found that when i place the mouse at upper left corner of
 the map i am receiving 2,2 instead of 0,0.

 As mentioned in the examples, this could be a bug. If so, please do fix
 and if their is a mistake in the way i have used the functionality then
 please let me know on how it should be corrected.

 Below is the simple html code that i am using


 {{{
 <html>
   <head>
     <title>OpenLayers Demo</title>
     <style type="text/css">
       html, body, #map {
           width: 500px;
           height: 500px;
           margin: 0;
       }
     </style>
     <script src="OpenLayers.js"></script>
     <script>
     var map;
       function init() {
         map = new OpenLayers.Map('map');
         var mapnik = new OpenLayers.Layer.OSM();
         map.addLayer(mapnik);
         map.setCenter(new OpenLayers.LonLat(13.41,52.52) // Center of the
 map
           .transform(
             new OpenLayers.Projection("EPSG:4326"), // transform from WGS
 1984
             new OpenLayers.Projection("EPSG:900913") // to Spherical
 Mercator Projection
           ), 15 // Zoom level
         );

                 map.events.register("mousemove", map, function(e) {
                 var position = this.events.getMousePosition(e);
                 OpenLayers.Util.getElement("coords").innerHTML = position;
                 });
       }
     </script>
   </head>
   <body onload="init();">
         <table>
         <tr>
             <td>
                 <div id="map" class="smallmap"></div>
                    <div id="basicMap"></div>
             </td>
             <td valign="top">
                 <div id="coords"></div>
             </td>
         </tr>
     </table>
   </body>
   <style type="text/css">
 DIV.olControlMousePosition {
         BOTTOM: 0em; DISPLAY: block; FONT-FAMILY: Arial; FONT-SIZE:
 smaller; RIGHT: 3px
 }
 </style>
 </html>
 }}}

 let me know if you need more information.

 Regards,
 Sanoj

-- 
Ticket URL: <http://trac.openlayers.org/ticket/2990>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list