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);
}