I have developed an app using Openlayers 2 to retrieve the latitude and longitude values based on the clicked position.
The map display the area of Great Britain and Northern Ireland.
Below the code I wrote for that.
var lonlat = self._map.getLonLatFromViewPortPx(evt.xy);
However Lonlat value it return is Latitude : 515881.5 and Longitude : 172199
I'm not sure whether these values are correct or not. Because Google map gives a different LonLat values for same area. [link]
The values from google maps are Latitude : 51.438677 Longitude : -0.335115
I want to know how to retrieve the LatLon from openlayers 2 if this is wrong.
Edit : This is the object returning from Openlayers end
initialize
lat
:
256465
lon
:
385906.5
__proto__
:
Object
CLASS_NAME
:
"OpenLayers.LonLat"
add
:
(lon, lat)
arguments
:
null
caller
:
null
length
:
2
name
:
"add"
prototype
:
Object
constructor
:
(lon, lat)
arguments
:
null
caller
:
null
length
:
2
name
:
"add"
prototype
:
Object
__proto__
:
()
[[FunctionLocation]]
:
OpenLayers.debug.js:1867
[[Scopes]]
:
Scopes[1]
0
:
Global
__proto__
:
Object
__proto__
:
()
[[FunctionLocation]]
:
OpenLayers.debug.js:1867
[[Scopes]]
:
Scopes[1]
clone
:
()
arguments
:
null
caller
:
null
length
:
0
name
:
"clone"
prototype
:
Object
__proto__
:
()
[[FunctionLocation]]
:
OpenLayers.debug.js:1852
[[Scopes]]
:
Scopes[1]
equals
:
(ll)
arguments
:
null
caller
:
null
length
:
1
name
:
"equals"
prototype
:
Object
__proto__
:
()
[[FunctionLocation]]
:
OpenLayers.debug.js:1887
[[Scopes]]
:
Scopes[1]
initialize
:
(lon, lat)
arguments
:
null
caller
:
null
fromArray
:
(arr)
fromString
:
(str)
length
:
2
name
:
"initialize"
prototype
:
Object
__proto__
:
()
[[FunctionLocation]]
:
OpenLayers.debug.js:1813
[[Scopes]]
:
Scopes[1]
lat
:
0
lon
:
0
toShortString
:
()
arguments
:
null
caller
:
null
length
:
0
name
:
"toShortString"
prototype
:
Object
__proto__
:
()
[[FunctionLocation]]
:
OpenLayers.debug.js:1841
[[Scopes]]
:
Scopes[1]
toString
:
()
arguments
:
null
caller
:
null
length
:
0
name
:
"toString"
prototype
:
Object
__proto__
:
()
[[FunctionLocation]]
:
OpenLayers.debug.js:1830
[[Scopes]]
:
Scopes[1]
transform
:
(source, dest)
arguments
:
null
caller
:
null
length
:
2
name
:
"transform"
prototype
:
Object
__proto__
:
()
[[FunctionLocation]]
:
OpenLayers.debug.js:1908
[[Scopes]]
:
Scopes[1]
0
:
Global
wrapDateLine
:
(maxExtent)
arguments
:
null
caller
:
null
length
:
1
name
:
"wrapDateLine"
prototype
:
Object
__proto__
:
()
[[FunctionLocation]]
:
OpenLayers.debug.js:1927
[[Scopes]]
:
Scopes[1]
__proto__
:
Object
Edit 2: These are my grid references "gridReference": "386170,256495",
Edit 3
projection: "EPSG:27700",
units: "m",
maxExtent: {
left: -521611.7877215,
bottom: -99060.2018315805,
right: 1107515.6274664556,
top: 1234593.14792
},
scales: [1.025694, 0.533333, 0.238194, 0.139583, 0.090278, 1.35, 1.17, 1.08, 1.04, 1.02],
resolutions: [1,0.5,0.25,0.1,0.05,0.025,0.0125,0.00625,0.003125,0.0015625,0.00078125],
controls: ["navigation", "panZoomBar", "scaleLine", "mousePosition", "attribution", "loadingPanel", "navigationHistory"],
controlPanel: {
controls: ["zoomBox", "measure", "getFeature"],
defaultControl: "panPanel"
}