0

I have some code that displays an OpenLayers map composed of various layers (vectors, markers and features) on top of an OpenStreetMaps basemap. Everything worked fine until some months back. Without any change in code, now, when i zoom my map, all superimposed layers lose their position relative to basemap/baselayer.

The OpenStreets basemap "slips" east as one zooms out.

Checking latlon pointer/mouse position reveals 4326 projection is working properly (as i zoom out, pointer is shown in a more westerly position, but retains same latlon pair value).

It is as if the basemap projected "wrong". All 6 layers are in sync with one another: if one layer "slips" west, all layers, except basemap, "slip" along with it.

I have tested this using various browsers (chromium, chrome and firefox) and the behavior is identical regardless of the browser.

var proj4326 = new OpenLayers.Projection("EPSG:4326");
var markerslayer = new OpenLayers.Layer.Markers( "New Markers" , {
    styleMap: new OpenLayers.StyleMap({
        "default": {
            graphicYOffset: 16,
            graphicYOffset: -6
        }
    })
});

var layerOSM = new OpenLayers.Layer.OSM("Street Map");
var map = new OpenLayers.Map({
 div: "map",
 layers: [
    layerOSM,
    markerslayer,
    //layerKMLClient,
    //layerKMLTarget,
    //layerKMLTrack, 
    //layerKMLStops
]
});

map.events.register("click", map, function(e) {
 var position = this.events.getMousePosition(e);
 var lonlat = map.getLonLatFromPixel(position);
 var lonlatTransf = lonlat.transform(map.getProjectionObject(), proj4326);
 var latTemp = lonlatTransf.lat;
 var lonTemp = lonlatTransf.lon;
 alert ('lonlatTrans=> lat='+lonlatTransf.lat+' lon='+lonlatTransf.lon+'\nlonlat=>'+lonlat+'\nposition=>'+position);
}
2

After searching high and low for an answer, i decided to simply update my OpenLayers javascript script (i had Release 2.12-rc4). So i downloaded OpenLayers.js Release 2.13.1 on the OpenLayers homepage.

Problem solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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