1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
| (L.TileLayer.WMTS = L.TileLayer.extend({
defaultWmtsParams: {
service: "WMTS",
request: "GetTile",
version: "1.0.0",
layer: "",
style: "",
tilematrixset: "",
format: "image/jpeg",
},
initialize: function (a, b) {
this._url = a;
var c = {},
d = Object.keys(b);
d.forEach((a) => {
c[a.toLowerCase()] = b[a];
});
var e = L.extend({ allowHeader: b.allowHeader }, this.defaultWmtsParams),
f = c.tileSize || this.options.tileSize;
for (var g in ((e.width =
c.detectRetina && L.Browser.retina ? (e.height = 2 * f) : (e.height = f)),
c))
e.hasOwnProperty(g) && "matrixIds" != g && (e[g] = c[g]);
(this.wmtsParams = e),
(this.matrixIds = b.matrixIds || this.getDefaultMatrix()),
L.setOptions(this, b);
},
onAdd: function (a) {
(this._crs = this.options.crs || a.options.crs),
L.TileLayer.prototype.onAdd.call(this, a);
},
getTileUrl: function (a) {
var b = this.options.tileSize,
c = a.multiplyBy(b);
(c.x += 1), (c.y -= 1);
var d = c.add(new L.Point(b, b)),
e = this._tileZoom,
f = this._crs.project(this._map.unproject(c, e)),
g = this._crs.project(this._map.unproject(d, e));
tilewidth = g.x - f.x;
var h = this.matrixIds[e].identifier,
i = this.wmtsParams.allowHeader
? this.wmtsParams.tilematrixset + ":" + h
: h,
j = this.matrixIds[e].topLeftCorner.lng,
k = this.matrixIds[e].topLeftCorner.lat,
l = Math.floor((f.x - j) / tilewidth),
m = -Math.floor((f.y - k) / tilewidth),
n = L.Util.template(this._url, { s: this._getSubdomain(a) });
return (
n +
L.Util.getParamString(this.wmtsParams, n) +
"&tilematrix=" +
i +
"&tilerow=" +
m +
"&tilecol=" +
l
);
},
setParams: function (a, b) {
return L.extend(this.wmtsParams, a), b || this.redraw(), this;
},
getDefaultMatrix: function () {
for (var a = Array(22), b = 0; 22 > b; b++)
a[b] = {
identifier: "" + b,
topLeftCorner: new L.LatLng(20037508.3428, -20037508.3428),
};
return a;
},
})),
(L.tileLayer.wmts = function (a, b) {
return new L.TileLayer.WMTS(a, b);
});
|