[OpenLayers-Users] OpenLayers with Yandex Traffic layer position issue
derinlik38
mehmett.ozkann at gmail.com
Tue Oct 20 01:29:18 PDT 2015
OpenLayers with Yandex layer position issue
http://jsfiddle.net/mozkan/4c20jjph/9/
<http://jsfiddle.net/mozkan/4c20jjph/9/>
<http://osgeo-org.1560.x6.nabble.com/file/n5231330/CYe4L.png>
var centerLat = 41.01165;
var centerLon = 29.07201;
var oldprojection = new OpenLayers.Projection("EPSG:4326");
var currprojection = new OpenLayers.Projection("EPSG:4326");
var geographic = new OpenLayers.Projection("EPSG:4326");
var mercator = new OpenLayers.Projection("EPSG:900913");
var options = {
projection : new OpenLayers.Projection("EPSG:900913"),
displayProjection : new OpenLayers.Projection("EPSG:4326"),
maxExtent: [-20037508.342789248, -20037508.342789248, 20037508.342789248,
20037508.342789248],
numZoomLevels : 19,
units : "m",
transitionEffect : null,
zoomMethod : null,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508,
20037508.34),
controls : [new OpenLayers.Control.Attribution(), new
OpenLayers.Control.KeyboardDefaults(), new
OpenLayers.Control.MousePosition(), new OpenLayers.Control.Navigation({
zoomWheelEnabled : true,
dragPanOptions : {
enableKinetic : true
}
})]
};
var map = new OpenLayers.Map('map',options);
var gmap = new OpenLayers.Layer.Google('Google Streets', {numZoomLevels :
18});
map.addLayers([gmap]);
function getTrafficLayerUrl1(e) {
console.log(e);
var d = map.getResolution() ;
console.log(this.maxExtent);
var x = Math.round((e.left - this.maxExtent.left) / (d * this.tileSize.w));
var y = Math.round((this.maxExtent.top - e.top) / (d * this.tileSize.h));
var f = map.getZoom();
var limit = Math.pow(2, f);
console.log(x+" "+y+" "+f+" "+limit);
if (y < 0 || y >= limit) {
// console.log("404");
return OpenLayers.Util.getImagesLocation() + "404.png";
} else {
x = ((x % limit) + limit) % limit;
var url = (this.url) ? this.url : "http://jgo.maps.yandex.net/1.1/";
return url + "tiles?l=trf&lang=tr_TR&z=" + f + "&x=" + x + "&y=" + (y) +
"&tm=1444759244";
}
}
var layerTraffic = new OpenLayers.Layer.TMS("TrafficLayer",
"http://jgo.maps.yandex.net/1.1/", {
visibility : true,
type : "png",
//tileOrigin: lonlat,
getURL : getTrafficLayerUrl1,
isBaseLayer : false,
transitionEffect : null,
zoomMethod : null,
});
map.addLayers([layerTraffic]);
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/OpenLayers-with-Yandex-Traffic-layer-position-issue-tp5231330.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list