nakarte

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

commit d6c9f09331c837da555234799635333f9bade709
parent 5ea8f75aaa007f755b697c5449d54e6850a16ddb
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Mon, 11 Nov 2019 22:10:43 +0100

custom layer: add variables for sas planet layers:

z_1 = z + 1
x_1024 = x // 1024
y_1024 = y // 1024

Diffstat:
Asrc/lib/leaflet.control.layers.configure/customLayer.js | 32++++++++++++++++++++++++++++++++
Msrc/lib/leaflet.control.layers.configure/index.js | 3++-
2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/src/lib/leaflet.control.layers.configure/customLayer.js b/src/lib/leaflet.control.layers.configure/customLayer.js @@ -0,0 +1,32 @@ +import L from 'leaflet'; + +L.Layer.CustomLayer = L.TileLayer.extend({ + getTileUrl: function (coords) { + const z = this._getZoomForUrl(); + var data = { + r: L.Browser.retina ? '@2x' : '', + s: this._getSubdomain(coords), + x: coords.x, + y: coords.y, + z: z, + z_1: z + 1, + x_1024: Math.floor(coords.x / 1024), + y_1024: Math.floor(coords.y / 1024), + }; + if (this._map && !this._map.options.crs.infinite) { + var invertedY = this._globalTileRange.max.y - coords.y; + if (this.options.tms) { + data['y'] = invertedY; + data['y_1024'] = Math.floor(invertedY / 1024); + } + data['-y'] = invertedY; + } + + return L.Util.template(this._url, L.extend(data, this.options)); + }, + + cloneForPrint: function(options) { + return new L.Layer.CustomLayer(this._url, L.Util.extend({}, this.options, options)); + }, + +}); diff --git a/src/lib/leaflet.control.layers.configure/index.js b/src/lib/leaflet.control.layers.configure/index.js @@ -5,6 +5,7 @@ import ko from 'vendored/knockout'; import {notify} from 'lib/notifications'; import logging from 'lib/logging'; import safeLocalStorage from 'lib/safe-localstorage'; +import './customLayer'; function enableConfig(control, {layers, customLayersOrder}) { const originalOnAdd = control.onAdd; @@ -384,7 +385,7 @@ function enableConfig(control, {layers, customLayersOrder}) { createCustomLayer: function(fieldValues) { const serialized = this.serializeCustomLayer(fieldValues); - const tileLayer = L.tileLayer(fieldValues.url, { + const tileLayer = new L.Layer.CustomLayer(fieldValues.url, { isOverlay: fieldValues.isOverlay, tms: fieldValues.tms, maxNativeZoom: fieldValues.maxZoom,