<span class="gI">I am trying to figure out how open layers converts a screen co ordinate into latitudes and longitudes. To figure it out I downloaded version 1 of open layers(for ease of reading due to less lines of code) and found the following function:<br>
<br> getLatLonFromPoint: function (point) {<br> var center = this.getCenter(); //map center lat/lon<br> var res = this.getResolution();<br> var size = this.getSize();<br> <br> var delta_x = point.x - (size.w / 2);<br>
var delta_y = point.y - (size.h / 2);<br> <br> return new OpenLayers.LatLon( <br> center.lat - delta_y * res, <br> center.lon + delta_x * res );<br> }<br clear="all"></span><br>
In the latest version this has changed a bit but the logic remains the same. <br><br>Can someone please let me know how this works. I searched for ways to convert a screen co ordinate to latitude and longitude and stumbled upon a couple of them. But, none of them seem to match what open layers is doing. <br>
<br>-- <br>Cheers,<br>Abhi<br>