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 have an OpenLayers map.

On to this I have loaded a GeoJSON file.

When I pan the map the GeoJSON data moves relative to the basemap.

Surely this isn't right! Can anyone shed some light no why this is happening?

share|improve this question
4  
please add a link to your code, it's very hard to debug from just a description of the problem –  iant Mar 22 '11 at 16:12
    
to add to what @iant said - you can use jsfiddle.net or jsbin.com to post some bare bones code to test. –  Vadim Mar 22 '11 at 16:43
    
Surley you want your georeferenced data to move relative to the other spatial data? –  geographika Mar 22 '11 at 17:06
    
We are waiting for the code, but it appears normal to me that the geojson data move when panning the basemap ... –  simo Mar 22 '11 at 17:08
1  
questioner is complaining the data moves relative to the base map - it's probably a projection issue –  iant Mar 23 '11 at 15:31

2 Answers 2

up vote 3 down vote accepted

This happened to me once and the layer was not on the same projection as the basemap.

But without example code, this is like a stab in the dark.

share|improve this answer
    
I'm having trouble reproducing the problem now - which is good - but I am having a slightly different problem. Now the overlays are aligned correctly (over Britain) when using osgeo.org basemap but are off the coast of Africa (0,0 in EPSG:4326 projection) when using Google or Microsoft. I'm almost certain it is a projection issue. I'll mark this as the correct answer - I can't reproduce the original problem so I can't test any other answers. Thanks all the same! –  Mr_Chimp Mar 31 '11 at 12:01

The most likely cause of this is not setting a baselayer's sphericalMercator property to true - by default this is false, so it needs to be set explicitly.

var myBaseLayer = new OpenLayers.Layer.Google("Google",
              {'sphericalMercator': true
              });

APIProperty: sphericalMecator Whether the tile extents should be set to the defaults for spherical mercator. Useful for things like OpenStreetMap. Default is false, except for the OSM subclass.

share|improve this answer

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.