nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

customLayer.js (1008B)


      1 import L from 'leaflet';
      2 
      3 L.Layer.CustomLayer = L.TileLayer.extend({
      4     getTileUrl: function(coords) {
      5         const z = this._getZoomForUrl();
      6         var data = {
      7             r: L.Browser.retina ? '@2x' : '',
      8             s: this._getSubdomain(coords),
      9             x: coords.x,
     10             y: coords.y,
     11             z: z,
     12             z_1: z + 1,
     13             x_1024: Math.floor(coords.x / 1024),
     14             y_1024: Math.floor(coords.y / 1024),
     15         };
     16         if (this._map && !this._map.options.crs.infinite) {
     17             var invertedY = this._globalTileRange.max.y - coords.y;
     18             if (this.options.tms) {
     19                 data['y'] = invertedY;
     20                 data['y_1024'] = Math.floor(invertedY / 1024);
     21             }
     22             data['-y'] = invertedY;
     23         }
     24 
     25         return L.Util.template(this._url, L.extend(data, this.options));
     26     },
     27 
     28     cloneForPrint: function(options) {
     29         return new L.Layer.CustomLayer(this._url, L.Util.extend({}, this.options, options));
     30     },
     31 
     32 });