I added a vector layer to my main map with the controls like the example from openlayers: http://openlayers.org/dev/examples/draw-feature.html

Now when I want to get the resulting lonlat from the point that was drawn I get strange results:

({id:"OpenLayers.Geometry.Point_81", x:6418264.3901563, y:7161906.3780079, 
      bounds:{left:6418264.3901563, bottom:7161906.3780079, right:6418264.3901563,

The main map is constructed like this:

map = new OpenLayers.Map( $('map'), {
    sphericalMercator: true,
    //maxResolution: '360/512',
    maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
    projection: "EPSG:900913",
    displayProjection: new OpenLayers.Projection("EPSG:4326"),
    tileOrigin: new OpenLayers.LonLat(-180, -90),
    controls: [new OpenLayers.Control.Navigation({dragPanOptions: {enableKinetic: true}}),
                   new OpenLayers.Control.MousePosition(),new OpenLayers.Control.Zoom()],

Can somebody give me a hint, it's probably an easy thing but I'm quite new to openlayers and javascript in general :-)

Something with the conversion of projection ?

1 Answer 1


this is not a strange result, it gives you coordinate as map.projection which you have defined in map options projection: "EPSG:900913"

try to use .transform method:

vectorLayers.features[1].geometry.transform(map.projection, map.displayProjection);

i hope it helps you...

  • SUPERB! I should've posted here much earlier, stuck on this for 48hours - solved in 5min. now Thank you very much.
    – jonas
    Sep 14, 2012 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.