Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an OSM-Layer as a base layer. When I create a vector I have to define the coordinates in meter.
Is there a way to use degrees right a way without reprojecting them beforehand to meters?

var p0 = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(13.39, 52.5));

share|improve this question

You can Transform on the fly, using the following code:

var geographic = new OpenLayers.Projection("EPSG:4326");
var mercator = new OpenLayers.Projection("EPSG:900913");
var p0 = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(13.39, 52.5).transform(geographic,mercator));
share|improve this answer
Thanks but is there no way to set the EPSG:4326 projection to the map or the layer so that everything will work with degrees? – strangeoptics Aug 16 '13 at 10:58
If you are using OSM layer, then the tiles are available only in EPSG:3857. If you want the map to be in EPSG:4326, then you cannot use the default OSM Layer in it. – Devdatta Tengshe Aug 16 '13 at 11:01
So you say there is no way to use degrees with the OSM Layer when working with Features? I have to reproject everything manually. – strangeoptics Aug 16 '13 at 11:08
@strangeoptics See my Update – Devdatta Tengshe Aug 16 '13 at 11:10
@strangeoptics: I rolled back the update, because as you have experienced, just setting the spatial reference on the layer does not work with manual Features. It works in other cases like using the WFS protocol, or using the KML protocol. – Devdatta Tengshe Aug 19 '13 at 9:59

You can define the projection of your layer. OpenLayers will reproject it automatically for you.

share|improve this answer
Maybe you can elaborate how to define it in OpenLayers. Might help the OP. – Curlew Aug 16 '13 at 12:49
@Devdatta Tengshe: has done it in his answer – neogeomat Aug 16 '13 at 16:25

Your Answer


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.