Reputation: 5143
I have a problem with converting pixel location from screen to degrees (EPSG4326).
The lon/lat value in EPSG900913 is correct, according to http://proj4js.org/ and google maps.
Some example values I'm getting are
EPSG:900913 lon: 2763836.8383036, lat: 8815158.7073107
after conversion
EPSG:4326 x: 79.18791 y: 24.08555
When the values should be
EPSG 4326: Y: 24.69090 X: 60.193680
Any ideas as to what I'm doing wrong?
Here's the relevant parts of my code.
$mapObj.bind("contextmenu.zoom", function (evt) {
var _px = new OpenLayers.Pixel(evt.pageX, evt.pageY),
_lonlat = _mapObj.getLonLatFromPixel(_px),
_point = new OpenLayers.Geometry.Point(_lonlat.lat, _lonlat.lon);
_point = _point.transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));
});
Upvotes: 2
Views: 1166
Reputation: 5143
... and the answer is, i mixed up lat & lon order on this row:
_point = new OpenLayers.Geometry.Point(_lonlat.lat, _lonlat.lon);
should be
_point = new OpenLayers.Geometry.Point(_lonlat.lon, _lonlat.lat);
Upvotes: 3