[GIS] Getting wrong lat/lang after transforming from “EPSG:900913” projection to “EPSG:4326”

openlayers

In OpenLayer3 Map I'm getting lat/lang from nominatim and the map is in "EPSG:900913" projection and then transforming it to "EPSG:4326" projection .

if lat = 12.9791198 and lang = 77.5912997 then i am transforming like this,

var point = new ol.geom.Point([lan,lat]);
point.transform("EPSG:4326","EPSG:900913");

After transformation lat/lang should be [8643375.747091185,1460888.081802196] but i am getting [8637423.97259228,-13864431.524951909].

Best Answer

While creating the point instance

var point = new ol.geom.Point([lon,lat]);

lon and lat value should be in numeric format previously they were in string format hence it was converting into wrong lat and long.