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 need to show a map (world map, used default OpenLayers WMS) and one point on it (with events like onhover, etc). Here is my code:

                   var options = {
                            projection: new OpenLayers.Projection("EPSG:900913"),
                            maxResolution: 6000
                        map = new OpenLayers.Map('map', options);

                        var wmsLayer = new OpenLayers.Layer.WMS(
                        "OpenLayers WMS", 
                        {layers: 'basic'}

                    var vectors = new OpenLayers.Layer.Vector("Vector Layer");

                    point = new OpenLayers.Geometry.Point(20.088844299316406, 51.8321709083475);
                    vectors.addFeatures([new OpenLayers.Feature.Vector(point)]);

                    map.addLayers([wmsLayer, vectors]);


But this code locates the point is drawn not in correct place, but somewhere near Africa (that place lat and lon is 0, 0). Question: Why this happens and can I fix it? I just need to locate the point to the correct place. Paradox when I print this point in console then it shows that the point lan and lon are as needed (as defined). But it is still in the wrong place...

share|improve this question
up vote 4 down vote accepted

You need to translate the point from lat/lon to your map projection:

point = new OpenLayers.Geometry.Point(20.088844299316406, 51.8321709083475);    
point.transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
vectors.addFeatures([new OpenLayers.Feature.Vector(point)]);

This will transform your variable point to the map projection.

share|improve this answer
This does not helped... point is still near Africa – Bob Oct 28 '12 at 19:27
fixed typo..... – djq Oct 28 '12 at 19:51

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.