Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am new to Openlayers and I am moving my application from Google Map to Openlayers. And also successfully displaying Polygons (coordinates captured via Google Map in Decimal Degrees - default for Google Maps), When I am drawing the polygon on a layer and on onFeaturesAdded Event, while getting co-ordinates of added feature like this

 var tArr = event.features[0].geometry.getVertices();

output comes out like

[POINT(-919690.32419922 -5068080.7227148),POINT(1780677.0106836 -6868325.6126367),POINT(1819812.7691602 -6868325.6126367)

But, while I am drawing this feature back to OpenLayers displays NOTHING.

Questions are :

1). Google Uses Decimal Degrees Notions to give points of Geometry, Openlayers give in which GIS notation ? (searched on web found nothing)

2). When I am saving co-ordinates in same Projection and redrawing it back, give nothing to me, why ?

thanks for any help.

share|improve this question
1  
Please explain what does it mean: "But, while I am drawing this feature back to OpenLayers"? –  drnextgis Feb 20 '13 at 15:09
1  
You need to be aware of something called 'Projection' of the map. Google Maps API can use lat-long values, even though the map is in web Mercator. In OpenLayers, if your map has a different projection than your point, you need to project it. Also: How are you drawing the points on the map? What code are you using? That might be the cause of the issue. –  Devdatta Tengshe Feb 23 '13 at 3:06
    
@drnextgis, my meaning from words, "But, while I am drawing this feature back to OpenLayers", was when I was adding polygon composed of Decimal Degrees coordinates to vector, It was displaying. –  philanthropist Feb 25 '13 at 6:36
    
@DevdattaTengshe, you are right, What I needed is Projection to the Map. Thanks alot, it solved my problem. –  philanthropist Feb 25 '13 at 6:38
add comment

1 Answer

If question is about converting geometry to string; and then converting string back to geometry, I suggest to use WKT format (http://en.wikipedia.org/wiki/Well-known_text).

Convert geometry to WKT string:

var myWkt = event.features[0].geometry.toString();

and re-creating geometry from WKT string:

var myGeom = new OpenLayers.Geometry.fromWKT(myWkt);
var myFeat = new OpenLayers.Feature.Vector(myGeom);
vectorLayer.addFeatures(myFeat);

And forget that Decimal degrees stuff :) It just means, coordinates are represented as decimal numbers (i.e. 25.5 instead of 25* 30').

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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