[GIS] lonlat from geometry point gives strange result

coordinate systemfeaturesopenlayers-2

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,
              top:7161906.3780079}})

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()],
eventListeners:{"moveend":mapEvent}
                                         });

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 ?

Best Answer

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...