OpenLayers with Yandex Traffic layer position issue [on hold]

Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

OpenLayers with Yandex Traffic layer position issue [on hold]

derinlik38
This post was updated on .
OpenLayers with Yandex layer position issue  

http://jsfiddle.net/mozkan/4c20jjph/9/


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