leaflet-tilelayer-swiss
Advanced tools
Comparing version 2.0.3 to 2.1.0
/*! | ||
* Leaflet.TileLayer.Swiss v2.0.3 | ||
* Leaflet.TileLayer.Swiss v2.1.0 | ||
* Plugin for displaying Swiss map tiles | ||
@@ -7,3 +7,3 @@ * © Roman Karavia | MIT License | ||
*/ | ||
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var L$1=_interopDefault(require("leaflet")),lv03="EPSG:21781",lv95="EPSG:2056";void 0===Number.isFinite&&(Number.isFinite=function(t){return"number"==typeof t&&isFinite(t)});var t=1e-12;function n(t){if(!Array.isArray(t))throw new Error("Expected input to be an array.");if(t.length<2)throw new Error("Expected input to be an array with length >= 2, got "+t.length+".");if(t.some((function(t){return!Number.isFinite(t)})))throw new Error("Expected all coordinates to be finite numbers.")}function r(t,n,a){return(a/60+n)/60+t}function o(t){return 180*t/Math.PI}function M(t){return t*Math.PI/180}function s(t,n){return{apply:function(a){var r=a[0],o=a[1],e=a.slice(2);return[r+t,o+n].concat(e)},unapply:function(a){var r=a[0],o=a[1],e=a.slice(2);return[r-t,o-n].concat(e)}}}var u=s(6e5,2e5),c=u.apply,p=u.unapply,l=s(26e5,12e5),v=l.apply,w=l.unapply,b=674.374,I=15.056,P=405.346;function m(n,a){var r=1/a,e=2*r-Math.pow(r,2);return{fromCartesian:function(a){for(var r,i,s,h=a[0],u=a[1],c=a[2],M=Math.atan(u/h),l=Math.sqrt(Math.pow(h,2)+Math.pow(u,2)),p=Math.atan(c/((1-e)*l));!(Math.abs(i-r)<t);)r=i,i=n/Math.sqrt(1-e*Math.pow(Math.sin(p),2)),s=l/Math.cos(p)-i,p=Math.atan(c/((1-e*i/(i+s))*l));var f=o(p);return[o(M),f,s]},toCartesian:function(t){var a=t[0],r=t[2];void 0===r&&(r=0);var o=M(t[1]),i=M(a),s=n/Math.sqrt(1-e*Math.pow(Math.sin(o),2));return[(s+r)*Math.cos(o)*Math.cos(i),(s+r)*Math.cos(o)*Math.sin(i),(s*(1-e)+r)*Math.sin(o)]}}}var d=m(6377397.155,299.15281285),x=d.fromCartesian,q=d.toCartesian,C=m(6378137,298.257223563),E=C.fromCartesian,F=C.toCartesian,N=1/299.15281285,A=M(r(46,57,8.66)),k=M(r(7,26,22.5)),z=2*N-Math.pow(N,2),B=6377397.155*Math.sqrt(1-z)/(1-z*Math.pow(Math.sin(A),2)),D=Math.sqrt(1+z/(1-z)*Math.pow(Math.cos(A),4)),G=Math.asin(Math.sin(A)/D),H=Math.sqrt(z),J=Math.log(Math.tan(Math.PI/4+G/2))-D*Math.log(Math.tan(Math.PI/4+A/2))+D*H/2*Math.log((1+H*Math.sin(A))/(1-H*Math.sin(A)));function K(t){var n,a,r,o,e,i,s,h,u,c=[(n=F(t))[0]-b,n[1]-I,n[2]-P],l=x(c),p=(a=l[0],r=M(l[1]),o=M(a),e=D*Math.log(Math.tan(Math.PI/4+r/2))-D*H/2*Math.log((1+H*Math.sin(r))/(1-H*Math.sin(r)))+J,i=2*(Math.atan(Math.exp(e))-Math.PI/4),s=D*(o-k),h=Math.asin(Math.cos(G)*Math.sin(i)-Math.sin(G)*Math.cos(i)*Math.cos(s)),u=Math.atan(Math.sin(s)/(Math.sin(G)*Math.tan(i)+Math.cos(G)*Math.cos(s))),[B*u,B/2*Math.log((1+Math.sin(h))/(1-Math.sin(h)))]);return t.length>2?p.concat([l[2]]):p}function L(n){var a=function(a){for(var r,e,i=n[0],s=2*(Math.atan(Math.exp(n[1]/B))-Math.PI/4),h=i/B,u=Math.asin(Math.cos(G)*Math.sin(s)+Math.sin(G)*Math.cos(s)*Math.cos(h)),c=Math.atan(Math.sin(h)/(Math.cos(G)*Math.cos(h)-Math.sin(G)*Math.tan(s))),M=k+c/D,l=u;!(Math.abs(e-r)<t);)r=e,e=(Math.log(Math.tan(Math.PI/4+u/2))-J)/D+H*Math.log(Math.tan(Math.PI/4+Math.asin(H*Math.sin(l))/2)),l=2*Math.atan(Math.exp(e))-Math.PI/2;var p=o(l);return[o(M),p]}();a.push(n[2]);var r,e=[(r=q(a))[0]+b,r[1]+I,r[2]+P],i=E(e);return n.length>2?i:i.slice(0,2)}var O={project:function(t){return n(t),c(K(t))},unproject:function(t){return n(t),L(p(t))}};function Q(t){return n(t),v(K(t))}function R(t){return n(t),L(w(t))}var S={project:Q,unproject:R},LV03_BOUNDS=L$1.bounds([42e4,3e4],[9e5,35e4]),LV95_BOUNDS=L$1.bounds([242e4,103e4],[29e5,135e4]);function leafletProjection(t,n){return{bounds:n,project:function(n){var a=n.lng,r=n.lat,o=t.project([a,r]),e=o[0],i=o[1];return L$1.point(e,i)},unproject:function(n){var a=n.x,r=n.y,o=t.unproject([a,r]),e=o[0],i=o[1];return L$1.latLng(i,e)}}}var lv03$1=leafletProjection(O,LV03_BOUNDS),lv95$1=leafletProjection(S,LV95_BOUNDS),RESOLUTIONS=[4e3,3750,3500,3250,3e3,2750,2500,2250,2e3,1750,1500,1250,1e3,750,650,500,250,100,50,20,10,5,2.5,2,1.5,1,.5,.25,.1];function fromZoom(t){if(t<0)return RESOLUTIONS[0];if(t>RESOLUTIONS.length-1)return RESOLUTIONS[RESOLUTIONS.length-1];var n=Math.floor(t);if(n===t)return RESOLUTIONS[t];var a=RESOLUTIONS[n],r=RESOLUTIONS[n+1]/a;return a*Math.pow(r,t-n)}function toZoom(t){for(var n=-1,a=0;a<RESOLUTIONS.length;a+=1)if(t>=RESOLUTIONS[a]){n=a;break}if(0===n)return 0;if(-1===n)return RESOLUTIONS.length-1;if(RESOLUTIONS[n]===t)return n;var r=RESOLUTIONS[n-1],o=RESOLUTIONS[n];return n+Math.log(o/t)/Math.log(r/o)}var CRS=L$1.Class.extend({includes:L$1.CRS,initialize:function(t){this.code=t.code,this.projection=t.projection;var n=this.projection.bounds.getBottomLeft();this.transformation=new L$1.Transformation(1,-n.x,-1,n.y),this.infinite=!1},scale:function(t){return 1/fromZoom(t)},zoom:function(t){return toZoom(1/t)},distance:function(t,n){var a=this.project(t),r=this.project(n);return a.distanceTo(r)}}),lv03$2=new CRS({code:lv03,projection:lv03$1}),lv95$2=new CRS({code:lv95,projection:lv95$1}),tileBounds=L$1.latLngBounds(lv95$2.unproject(lv95$2.projection.bounds.min),lv95$2.unproject(lv95$2.projection.bounds.max)),switzerlandBounds=L$1.latLngBounds(lv95$2.unproject(L$1.point(2485e3,1075e3)),lv95$2.unproject(L$1.point(2835e3,1295e3))),urlsByCrs={};urlsByCrs[lv03]="https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/21781/{z}/{y}/{x}.{format}",urlsByCrs[lv95]="https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/2056/{z}/{x}/{y}.{format}",L$1.CRS.EPSG21781=lv03$2,L$1.CRS.EPSG2056=lv95$2;var Swiss=L$1.TileLayer.extend({options:{attribution:'© <a href="https://www.swisstopo.ch/" target="_blank">Swisstopo</a>',bounds:tileBounds,crs:lv95$2,format:"jpeg",layer:"ch.swisstopo.pixelkarte-farbe",minZoom:14,maxNativeZoom:27,maxZoom:28,subdomains:"0123456789",switzerlandBounds:switzerlandBounds,timestamp:"current"},initialize:function(t){L$1.setOptions(this,t);var n=this.options.url||urlsByCrs[this.options.crs.code];L$1.TileLayer.prototype.initialize.call(this,n,this.options)}});L$1.tileLayer.swiss=function(t){return new Swiss(t)},module.exports=Swiss; | ||
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var L$1=_interopDefault(require("leaflet")),lv03="EPSG:21781",lv95="EPSG:2056";void 0===Number.isFinite&&(Number.isFinite=function(t){return"number"==typeof t&&isFinite(t)});var t=1e-12;function n(t){if(!Array.isArray(t))throw new Error("Expected input to be an array.");if(t.length<2)throw new Error("Expected input to be an array with length >= 2, got "+t.length+".");if(t.some((function(t){return!Number.isFinite(t)})))throw new Error("Expected all coordinates to be finite numbers.")}function r(t,n,a){return(a/60+n)/60+t}function o(t){return 180*t/Math.PI}function M(t){return t*Math.PI/180}function s(t,n){return{apply:function(a){var o=a[0],r=a[1],e=a.slice(2);return[o+t,r+n].concat(e)},unapply:function(a){var o=a[0],r=a[1],e=a.slice(2);return[o-t,r-n].concat(e)}}}var u=s(6e5,2e5),c=u.apply,p=u.unapply,l=s(26e5,12e5),v=l.apply,w=l.unapply,b=674.374,I=15.056,P=405.346;function m(n,a){var r=1/a,e=2*r-Math.pow(r,2);return{fromCartesian:function(a){for(var r,i,s,h=a[0],u=a[1],c=a[2],l=Math.atan(u/h),M=Math.sqrt(Math.pow(h,2)+Math.pow(u,2)),p=Math.atan(c/((1-e)*M));!(Math.abs(i-r)<t);)r=i,i=n/Math.sqrt(1-e*Math.pow(Math.sin(p),2)),s=M/Math.cos(p)-i,p=Math.atan(c/((1-e*i/(i+s))*M));var f=o(p);return[o(l),f,s]},toCartesian:function(t){var a=t[0],o=t[2];void 0===o&&(o=0);var r=M(t[1]),i=M(a),s=n/Math.sqrt(1-e*Math.pow(Math.sin(r),2));return[(s+o)*Math.cos(r)*Math.cos(i),(s+o)*Math.cos(r)*Math.sin(i),(s*(1-e)+o)*Math.sin(r)]}}}var d=m(6377397.155,299.15281285),x=d.fromCartesian,q=d.toCartesian,C=m(6378137,298.257223563),E=C.fromCartesian,F=C.toCartesian,N=1/299.15281285,A=M(r(46,57,8.66)),k=M(r(7,26,22.5)),z=2*N-Math.pow(N,2),B=6377397.155*Math.sqrt(1-z)/(1-z*Math.pow(Math.sin(A),2)),D=Math.sqrt(1+z/(1-z)*Math.pow(Math.cos(A),4)),G=Math.asin(Math.sin(A)/D),H=Math.sqrt(z),J=Math.log(Math.tan(Math.PI/4+G/2))-D*Math.log(Math.tan(Math.PI/4+A/2))+D*H/2*Math.log((1+H*Math.sin(A))/(1-H*Math.sin(A)));function K(t){var n,a,o,r,e,i,s,h,u,c=[(n=F(t))[0]-b,n[1]-I,n[2]-P],l=x(c),p=(a=l[0],o=M(l[1]),r=M(a),e=D*Math.log(Math.tan(Math.PI/4+o/2))-D*H/2*Math.log((1+H*Math.sin(o))/(1-H*Math.sin(o)))+J,i=2*(Math.atan(Math.exp(e))-Math.PI/4),s=D*(r-k),h=Math.asin(Math.cos(G)*Math.sin(i)-Math.sin(G)*Math.cos(i)*Math.cos(s)),u=Math.atan(Math.sin(s)/(Math.sin(G)*Math.tan(i)+Math.cos(G)*Math.cos(s))),[B*u,B/2*Math.log((1+Math.sin(h))/(1-Math.sin(h)))]);return t.length>2?p.concat([l[2]]):p}function L(n){var a=function(a){for(var r,e,i=n[0],s=2*(Math.atan(Math.exp(n[1]/B))-Math.PI/4),h=i/B,u=Math.asin(Math.cos(G)*Math.sin(s)+Math.sin(G)*Math.cos(s)*Math.cos(h)),c=Math.atan(Math.sin(h)/(Math.cos(G)*Math.cos(h)-Math.sin(G)*Math.tan(s))),l=k+c/D,M=u;!(Math.abs(e-r)<t);)r=e,e=(Math.log(Math.tan(Math.PI/4+u/2))-J)/D+H*Math.log(Math.tan(Math.PI/4+Math.asin(H*Math.sin(M))/2)),M=2*Math.atan(Math.exp(e))-Math.PI/2;var p=o(M);return[o(l),p]}();a.push(n[2]);var r,e=[(r=q(a))[0]+b,r[1]+I,r[2]+P],i=E(e);return n.length>2?i:i.slice(0,2)}var O={project:function(t){return n(t),c(K(t))},unproject:function(t){return n(t),L(p(t))}};function Q(t){return n(t),v(K(t))}function R(t){return n(t),L(w(t))}var S={project:Q,unproject:R},LV03_BOUNDS=L$1.bounds([42e4,3e4],[9e5,35e4]),LV95_BOUNDS=L$1.bounds([242e4,103e4],[29e5,135e4]);function leafletProjection(t,n){return{bounds:n,project:function(n){var a=n.lng,o=n.lat,r=t.project([a,o]),e=r[0],i=r[1];return L$1.point(e,i)},unproject:function(n){var a=n.x,o=n.y,r=t.unproject([a,o]),e=r[0],i=r[1];return L$1.latLng(i,e)}}}var lv03$1=leafletProjection(O,LV03_BOUNDS),lv95$1=leafletProjection(S,LV95_BOUNDS),RESOLUTIONS=[4e3,3750,3500,3250,3e3,2750,2500,2250,2e3,1750,1500,1250,1e3,750,650,500,250,100,50,20,10,5,2.5,2,1.5,1,.5,.25,.1];function fromZoom(t){if(t<0)return RESOLUTIONS[0];if(t>RESOLUTIONS.length-1)return RESOLUTIONS[RESOLUTIONS.length-1];var n=Math.floor(t);if(n===t)return RESOLUTIONS[t];var a=RESOLUTIONS[n],o=RESOLUTIONS[n+1]/a;return a*Math.pow(o,t-n)}function toZoom(t){for(var n=-1,a=0;a<RESOLUTIONS.length;a+=1)if(t>=RESOLUTIONS[a]){n=a;break}if(0===n)return 0;if(-1===n)return RESOLUTIONS.length-1;if(RESOLUTIONS[n]===t)return n;var o=RESOLUTIONS[n-1],r=RESOLUTIONS[n];return n+Math.log(r/t)/Math.log(o/r)}var CRS=L$1.Class.extend({includes:L$1.CRS,initialize:function(t){this.code=t.code,this.projection=t.projection;var n=this.projection.bounds.getBottomLeft();this.transformation=new L$1.Transformation(1,-n.x,-1,n.y),this.infinite=!1},scale:function(t){return 1/fromZoom(t)},zoom:function(t){return toZoom(1/t)},distance:function(t,n){var a=this.project(t),o=this.project(n);return a.distanceTo(o)}}),lv03$2=new CRS({code:lv03,projection:lv03$1}),lv95$2=new CRS({code:lv95,projection:lv95$1}),tileBounds=L$1.latLngBounds(lv95$2.unproject(lv95$2.projection.bounds.min),lv95$2.unproject(lv95$2.projection.bounds.max)),switzerlandBounds=L$1.latLngBounds(lv95$2.unproject(L$1.point(2485e3,1075e3)),lv95$2.unproject(L$1.point(2835e3,1295e3))),urlsByCrs={};urlsByCrs[lv03]="https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/21781/{z}/{y}/{x}.{format}",urlsByCrs[lv95]="https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/2056/{z}/{x}/{y}.{format}";var SwissLayer=L$1.TileLayer.extend({options:{attribution:'© <a href="https://www.swisstopo.ch/" target="_blank">Swisstopo</a>',bounds:tileBounds,crs:lv95$2,format:"jpeg",layer:"ch.swisstopo.pixelkarte-farbe",minZoom:14,maxNativeZoom:27,maxZoom:28,subdomains:"0123456789",timestamp:"current"},initialize:function(t){L$1.setOptions(this,t);var n=this.options.url||urlsByCrs[this.options.crs.code];L$1.TileLayer.prototype.initialize.call(this,n,this.options)}});L$1.CRS.EPSG21781=lv03$2,L$1.CRS.EPSG2056=lv95$2,L$1.TileLayer.Swiss=SwissLayer,L$1.tileLayer.swiss=function(t){return new SwissLayer(t)},L$1.Map.addInitHook((function(){this.options.maxBounds||this.options.crs!==lv03$2&&this.options.crs!==lv95$2||this.setMaxBounds(tileBounds)})),L$1.Map.include({fitSwitzerland:function(){this.fitBounds(switzerlandBounds)}}),module.exports=SwissLayer; | ||
//# sourceMappingURL=Leaflet.TileLayer.Swiss.cjs.js.map |
/*! | ||
* Leaflet.TileLayer.Swiss v2.0.3 | ||
* Leaflet.TileLayer.Swiss v2.1.0 | ||
* Plugin for displaying Swiss map tiles | ||
@@ -7,3 +7,3 @@ * © Roman Karavia | MIT License | ||
*/ | ||
import t from"leaflet";void 0===Number.isFinite&&(Number.isFinite=function(t){return"number"==typeof t&&isFinite(t)});var a=1e-12;function n(t){if(!Array.isArray(t))throw new Error("Expected input to be an array.");if(t.length<2)throw new Error("Expected input to be an array with length >= 2, got "+t.length+".");if(t.some((function(t){return!Number.isFinite(t)})))throw new Error("Expected all coordinates to be finite numbers.")}function r(t,a,n){return(n/60+a)/60+t}function o(t){return 180*t/Math.PI}function e(t){return t*Math.PI/180}function i(t,a){return{apply:function(n){var r=n[0],o=n[1],e=n.slice(2);return[r+t,o+a].concat(e)},unapply:function(n){var r=n[0],o=n[1],e=n.slice(2);return[r-t,o-a].concat(e)}}}var h=i(6e5,2e5),s=h.apply,u=h.unapply,c=i(26e5,12e5),M=c.apply,p=c.unapply,f=674.374,l=15.056,m=405.346;function d(t,n){var r=1/n,i=2*r-Math.pow(r,2);return{fromCartesian:function(n){for(var r,e,h,s=n[0],u=n[1],c=n[2],M=Math.atan(u/s),p=Math.sqrt(Math.pow(s,2)+Math.pow(u,2)),f=Math.atan(c/((1-i)*p));!(Math.abs(e-r)<a);)r=e,e=t/Math.sqrt(1-i*Math.pow(Math.sin(f),2)),h=p/Math.cos(f)-e,f=Math.atan(c/((1-i*e/(e+h))*p));var l=o(f);return[o(M),l,h]},toCartesian:function(a){var n=a[0],r=a[2];void 0===r&&(r=0);var o=e(a[1]),h=e(n),s=t/Math.sqrt(1-i*Math.pow(Math.sin(o),2));return[(s+r)*Math.cos(o)*Math.cos(h),(s+r)*Math.cos(o)*Math.sin(h),(s*(1-i)+r)*Math.sin(o)]}}}var v=d(6377397.155,299.15281285),w=v.fromCartesian,g=v.toCartesian,b=d(6378137,298.257223563),j=b.fromCartesian,y=b.toCartesian,x=1/299.15281285,P=e(r(46,57,8.66)),E=e(r(7,26,22.5)),C=2*x-Math.pow(x,2),I=6377397.155*Math.sqrt(1-C)/(1-C*Math.pow(Math.sin(P),2)),S=Math.sqrt(1+C/(1-C)*Math.pow(Math.cos(P),4)),z=Math.asin(Math.sin(P)/S),L=Math.sqrt(C),q=Math.log(Math.tan(Math.PI/4+z/2))-S*Math.log(Math.tan(Math.PI/4+P/2))+S*L/2*Math.log((1+L*Math.sin(P))/(1-L*Math.sin(P)));function G(t){var a,n,r,o,i,h,s,u,c,M=[(a=y(t))[0]-f,a[1]-l,a[2]-m],p=w(M),d=(n=p[0],r=e(p[1]),o=e(n),i=S*Math.log(Math.tan(Math.PI/4+r/2))-S*L/2*Math.log((1+L*Math.sin(r))/(1-L*Math.sin(r)))+q,h=2*(Math.atan(Math.exp(i))-Math.PI/4),s=S*(o-E),u=Math.asin(Math.cos(z)*Math.sin(h)-Math.sin(z)*Math.cos(h)*Math.cos(s)),c=Math.atan(Math.sin(s)/(Math.sin(z)*Math.tan(h)+Math.cos(z)*Math.cos(s))),[I*c,I/2*Math.log((1+Math.sin(u))/(1-Math.sin(u)))]);return t.length>2?d.concat([p[2]]):d}function B(t){var n=function(n){for(var r,e,i=t[0],h=2*(Math.atan(Math.exp(t[1]/I))-Math.PI/4),s=i/I,u=Math.asin(Math.cos(z)*Math.sin(h)+Math.sin(z)*Math.cos(h)*Math.cos(s)),c=Math.atan(Math.sin(s)/(Math.cos(z)*Math.cos(s)-Math.sin(z)*Math.tan(h))),M=E+c/S,p=u;!(Math.abs(e-r)<a);)r=e,e=(Math.log(Math.tan(Math.PI/4+u/2))-q)/S+L*Math.log(Math.tan(Math.PI/4+Math.asin(L*Math.sin(p))/2)),p=2*Math.atan(Math.exp(e))-Math.PI/2;var f=o(p);return[o(M),f]}();n.push(t[2]);var r,e=[(r=g(n))[0]+f,r[1]+l,r[2]+m],i=j(e);return t.length>2?i:i.slice(0,2)}var F={project:function(t){return n(t),s(G(t))},unproject:function(t){return n(t),B(u(t))}};var N={project:function(t){return n(t),M(G(t))},unproject:function(t){return n(t),B(p(t))}},T=t.bounds([42e4,3e4],[9e5,35e4]),k=t.bounds([242e4,103e4],[29e5,135e4]);function R(a,n){return{bounds:n,project:function(n){var r=n.lng,o=n.lat,e=a.project([r,o]),i=e[0],h=e[1];return t.point(i,h)},unproject:function(n){var r=n.x,o=n.y,e=a.unproject([r,o]),i=e[0],h=e[1];return t.latLng(h,i)}}}var Z=R(F,T),A=R(N,k),O=[4e3,3750,3500,3250,3e3,2750,2500,2250,2e3,1750,1500,1250,1e3,750,650,500,250,100,50,20,10,5,2.5,2,1.5,1,.5,.25,.1];var _=t.Class.extend({includes:t.CRS,initialize:function(a){this.code=a.code,this.projection=a.projection;var n=this.projection.bounds.getBottomLeft();this.transformation=new t.Transformation(1,-n.x,-1,n.y),this.infinite=!1},scale:function(t){return 1/function(t){if(t<0)return O[0];if(t>O.length-1)return O[O.length-1];var a=Math.floor(t);if(a===t)return O[t];var n=O[a],r=O[a+1]/n;return n*Math.pow(r,t-a)}(t)},zoom:function(t){return function(t){for(var a=-1,n=0;n<O.length;n+=1)if(t>=O[n]){a=n;break}if(0===a)return 0;if(-1===a)return O.length-1;if(O[a]===t)return a;var r=O[a-1],o=O[a];return a+Math.log(o/t)/Math.log(r/o)}(1/t)},distance:function(t,a){var n=this.project(t),r=this.project(a);return n.distanceTo(r)}}),D=new _({code:"EPSG:21781",projection:Z}),H=new _({code:"EPSG:2056",projection:A}),J=t.latLngBounds(H.unproject(H.projection.bounds.min),H.unproject(H.projection.bounds.max)),K=t.latLngBounds(H.unproject(t.point(2485e3,1075e3)),H.unproject(t.point(2835e3,1295e3))),Q={"EPSG:21781":"https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/21781/{z}/{y}/{x}.{format}","EPSG:2056":"https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/2056/{z}/{x}/{y}.{format}"};t.CRS.EPSG21781=D,t.CRS.EPSG2056=H;var U=t.TileLayer.extend({options:{attribution:'© <a href="https://www.swisstopo.ch/" target="_blank">Swisstopo</a>',bounds:J,crs:H,format:"jpeg",layer:"ch.swisstopo.pixelkarte-farbe",minZoom:14,maxNativeZoom:27,maxZoom:28,subdomains:"0123456789",switzerlandBounds:K,timestamp:"current"},initialize:function(a){t.setOptions(this,a);var n=this.options.url||Q[this.options.crs.code];t.TileLayer.prototype.initialize.call(this,n,this.options)}});t.tileLayer.swiss=function(t){return new U(t)};export default U; | ||
import t from"leaflet";void 0===Number.isFinite&&(Number.isFinite=function(t){return"number"==typeof t&&isFinite(t)});var n=1e-12;function a(t){if(!Array.isArray(t))throw new Error("Expected input to be an array.");if(t.length<2)throw new Error("Expected input to be an array with length >= 2, got "+t.length+".");if(t.some((function(t){return!Number.isFinite(t)})))throw new Error("Expected all coordinates to be finite numbers.")}function o(t,n,a){return(a/60+n)/60+t}function r(t){return 180*t/Math.PI}function e(t){return t*Math.PI/180}function i(t,n){return{apply:function(a){var o=a[0],r=a[1],e=a.slice(2);return[o+t,r+n].concat(e)},unapply:function(a){var o=a[0],r=a[1],e=a.slice(2);return[o-t,r-n].concat(e)}}}var s=i(6e5,2e5),h=s.apply,u=s.unapply,c=i(26e5,12e5),M=c.apply,p=c.unapply,f=674.374,l=15.056,d=405.346;function m(t,a){var o=1/a,i=2*o-Math.pow(o,2);return{fromCartesian:function(a){for(var o,e,s,h=a[0],u=a[1],c=a[2],M=Math.atan(u/h),p=Math.sqrt(Math.pow(h,2)+Math.pow(u,2)),f=Math.atan(c/((1-i)*p));!(Math.abs(e-o)<n);)o=e,e=t/Math.sqrt(1-i*Math.pow(Math.sin(f),2)),s=p/Math.cos(f)-e,f=Math.atan(c/((1-i*e/(e+s))*p));var l=r(f);return[r(M),l,s]},toCartesian:function(n){var a=n[0],o=n[2];void 0===o&&(o=0);var r=e(n[1]),s=e(a),h=t/Math.sqrt(1-i*Math.pow(Math.sin(r),2));return[(h+o)*Math.cos(r)*Math.cos(s),(h+o)*Math.cos(r)*Math.sin(s),(h*(1-i)+o)*Math.sin(r)]}}}var v=m(6377397.155,299.15281285),w=v.fromCartesian,g=v.toCartesian,y=m(6378137,298.257223563),b=y.fromCartesian,j=y.toCartesian,x=1/299.15281285,P=e(o(46,57,8.66)),E=e(o(7,26,22.5)),S=2*x-Math.pow(x,2),I=6377397.155*Math.sqrt(1-S)/(1-S*Math.pow(Math.sin(P),2)),C=Math.sqrt(1+S/(1-S)*Math.pow(Math.cos(P),4)),L=Math.asin(Math.sin(P)/C),z=Math.sqrt(S),q=Math.log(Math.tan(Math.PI/4+L/2))-C*Math.log(Math.tan(Math.PI/4+P/2))+C*z/2*Math.log((1+z*Math.sin(P))/(1-z*Math.sin(P)));function B(t){var n,a,o,r,i,s,h,u,c,M=[(n=j(t))[0]-f,n[1]-l,n[2]-d],p=w(M),m=(a=p[0],o=e(p[1]),r=e(a),i=C*Math.log(Math.tan(Math.PI/4+o/2))-C*z/2*Math.log((1+z*Math.sin(o))/(1-z*Math.sin(o)))+q,s=2*(Math.atan(Math.exp(i))-Math.PI/4),h=C*(r-E),u=Math.asin(Math.cos(L)*Math.sin(s)-Math.sin(L)*Math.cos(s)*Math.cos(h)),c=Math.atan(Math.sin(h)/(Math.sin(L)*Math.tan(s)+Math.cos(L)*Math.cos(h))),[I*c,I/2*Math.log((1+Math.sin(u))/(1-Math.sin(u)))]);return t.length>2?m.concat([p[2]]):m}function G(t){var a=function(a){for(var o,e,i=t[0],s=2*(Math.atan(Math.exp(t[1]/I))-Math.PI/4),h=i/I,u=Math.asin(Math.cos(L)*Math.sin(s)+Math.sin(L)*Math.cos(s)*Math.cos(h)),c=Math.atan(Math.sin(h)/(Math.cos(L)*Math.cos(h)-Math.sin(L)*Math.tan(s))),M=E+c/C,p=u;!(Math.abs(e-o)<n);)o=e,e=(Math.log(Math.tan(Math.PI/4+u/2))-q)/C+z*Math.log(Math.tan(Math.PI/4+Math.asin(z*Math.sin(p))/2)),p=2*Math.atan(Math.exp(e))-Math.PI/2;var f=r(p);return[r(M),f]}();a.push(t[2]);var o,e=[(o=g(a))[0]+f,o[1]+l,o[2]+d],i=b(e);return t.length>2?i:i.slice(0,2)}var T={project:function(t){return a(t),h(B(t))},unproject:function(t){return a(t),G(u(t))}};var k={project:function(t){return a(t),M(B(t))},unproject:function(t){return a(t),G(p(t))}},F=t.bounds([42e4,3e4],[9e5,35e4]),N=t.bounds([242e4,103e4],[29e5,135e4]);function R(n,a){return{bounds:a,project:function(a){var o=a.lng,r=a.lat,e=n.project([o,r]),i=e[0],s=e[1];return t.point(i,s)},unproject:function(a){var o=a.x,r=a.y,e=n.unproject([o,r]),i=e[0],s=e[1];return t.latLng(s,i)}}}var Z=R(T,F),A=R(k,N),H=[4e3,3750,3500,3250,3e3,2750,2500,2250,2e3,1750,1500,1250,1e3,750,650,500,250,100,50,20,10,5,2.5,2,1.5,1,.5,.25,.1];var O=t.Class.extend({includes:t.CRS,initialize:function(n){this.code=n.code,this.projection=n.projection;var a=this.projection.bounds.getBottomLeft();this.transformation=new t.Transformation(1,-a.x,-1,a.y),this.infinite=!1},scale:function(t){return 1/function(t){if(t<0)return H[0];if(t>H.length-1)return H[H.length-1];var n=Math.floor(t);if(n===t)return H[t];var a=H[n],o=H[n+1]/a;return a*Math.pow(o,t-n)}(t)},zoom:function(t){return function(t){for(var n=-1,a=0;a<H.length;a+=1)if(t>=H[a]){n=a;break}if(0===n)return 0;if(-1===n)return H.length-1;if(H[n]===t)return n;var o=H[n-1],r=H[n];return n+Math.log(r/t)/Math.log(o/r)}(1/t)},distance:function(t,n){var a=this.project(t),o=this.project(n);return a.distanceTo(o)}}),_=new O({code:"EPSG:21781",projection:Z}),D=new O({code:"EPSG:2056",projection:A}),J=t.latLngBounds(D.unproject(D.projection.bounds.min),D.unproject(D.projection.bounds.max)),K=t.latLngBounds(D.unproject(t.point(2485e3,1075e3)),D.unproject(t.point(2835e3,1295e3))),Q={"EPSG:21781":"https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/21781/{z}/{y}/{x}.{format}","EPSG:2056":"https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/2056/{z}/{x}/{y}.{format}"},U=t.TileLayer.extend({options:{attribution:'© <a href="https://www.swisstopo.ch/" target="_blank">Swisstopo</a>',bounds:J,crs:D,format:"jpeg",layer:"ch.swisstopo.pixelkarte-farbe",minZoom:14,maxNativeZoom:27,maxZoom:28,subdomains:"0123456789",timestamp:"current"},initialize:function(n){t.setOptions(this,n);var a=this.options.url||Q[this.options.crs.code];t.TileLayer.prototype.initialize.call(this,a,this.options)}});t.CRS.EPSG21781=_,t.CRS.EPSG2056=D,t.TileLayer.Swiss=U,t.tileLayer.swiss=function(t){return new U(t)},t.Map.addInitHook((function(){this.options.maxBounds||this.options.crs!==_&&this.options.crs!==D||this.setMaxBounds(J)})),t.Map.include({fitSwitzerland:function(){this.fitBounds(K)}});export default U; | ||
//# sourceMappingURL=Leaflet.TileLayer.Swiss.esm.js.map |
/*! | ||
* Leaflet.TileLayer.Swiss v2.0.3 | ||
* Leaflet.TileLayer.Swiss v2.1.0 | ||
* Plugin for displaying Swiss map tiles | ||
@@ -7,3 +7,3 @@ * © Roman Karavia | MIT License | ||
*/ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("leaflet")):"function"==typeof define&&define.amd?define(["leaflet"],n):((t=t||self).L=t.L||{},t.L.TileLayer=t.L.TileLayer||{},t.L.TileLayer.Swiss=n(t.L))}(this,(function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;void 0===Number.isFinite&&(Number.isFinite=function(t){return"number"==typeof t&&isFinite(t)});var n=1e-12;function a(t){if(!Array.isArray(t))throw new Error("Expected input to be an array.");if(t.length<2)throw new Error("Expected input to be an array with length >= 2, got "+t.length+".");if(t.some((function(t){return!Number.isFinite(t)})))throw new Error("Expected all coordinates to be finite numbers.")}function e(t,n,a){return(a/60+n)/60+t}function r(t){return 180*t/Math.PI}function o(t){return t*Math.PI/180}function i(t,n){return{apply:function(a){var e=a[0],r=a[1],o=a.slice(2);return[e+t,r+n].concat(o)},unapply:function(a){var e=a[0],r=a[1],o=a.slice(2);return[e-t,r-n].concat(o)}}}var s=i(6e5,2e5),h=s.apply,u=s.unapply,c=i(26e5,12e5),M=c.apply,p=c.unapply,f=674.374,l=15.056,d=405.346;function m(t,a){var e=1/a,i=2*e-Math.pow(e,2);return{fromCartesian:function(a){for(var e,o,s,h=a[0],u=a[1],c=a[2],M=Math.atan(u/h),p=Math.sqrt(Math.pow(h,2)+Math.pow(u,2)),f=Math.atan(c/((1-i)*p));!(Math.abs(o-e)<n);)e=o,o=t/Math.sqrt(1-i*Math.pow(Math.sin(f),2)),s=p/Math.cos(f)-o,f=Math.atan(c/((1-i*o/(o+s))*p));var l=r(f);return[r(M),l,s]},toCartesian:function(n){var a=n[0],e=n[2];void 0===e&&(e=0);var r=o(n[1]),s=o(a),h=t/Math.sqrt(1-i*Math.pow(Math.sin(r),2));return[(h+e)*Math.cos(r)*Math.cos(s),(h+e)*Math.cos(r)*Math.sin(s),(h*(1-i)+e)*Math.sin(r)]}}}var v=m(6377397.155,299.15281285),w=v.fromCartesian,g=v.toCartesian,y=m(6378137,298.257223563),b=y.fromCartesian,j=y.toCartesian,x=1/299.15281285,P=o(e(46,57,8.66)),L=o(e(7,26,22.5)),E=2*x-Math.pow(x,2),S=6377397.155*Math.sqrt(1-E)/(1-E*Math.pow(Math.sin(P),2)),C=Math.sqrt(1+E/(1-E)*Math.pow(Math.cos(P),4)),I=Math.asin(Math.sin(P)/C),q=Math.sqrt(E),z=Math.log(Math.tan(Math.PI/4+I/2))-C*Math.log(Math.tan(Math.PI/4+P/2))+C*q/2*Math.log((1+q*Math.sin(P))/(1-q*Math.sin(P)));function T(t){var n,a,e,r,i,s,h,u,c,M=[(n=j(t))[0]-f,n[1]-l,n[2]-d],p=w(M),m=(a=p[0],e=o(p[1]),r=o(a),i=C*Math.log(Math.tan(Math.PI/4+e/2))-C*q/2*Math.log((1+q*Math.sin(e))/(1-q*Math.sin(e)))+z,s=2*(Math.atan(Math.exp(i))-Math.PI/4),h=C*(r-L),u=Math.asin(Math.cos(I)*Math.sin(s)-Math.sin(I)*Math.cos(s)*Math.cos(h)),c=Math.atan(Math.sin(h)/(Math.sin(I)*Math.tan(s)+Math.cos(I)*Math.cos(h))),[S*c,S/2*Math.log((1+Math.sin(u))/(1-Math.sin(u)))]);return t.length>2?m.concat([p[2]]):m}function G(t){var a=function(a){for(var e,o,i=t[0],s=2*(Math.atan(Math.exp(t[1]/S))-Math.PI/4),h=i/S,u=Math.asin(Math.cos(I)*Math.sin(s)+Math.sin(I)*Math.cos(s)*Math.cos(h)),c=Math.atan(Math.sin(h)/(Math.cos(I)*Math.cos(h)-Math.sin(I)*Math.tan(s))),M=L+c/C,p=u;!(Math.abs(o-e)<n);)e=o,o=(Math.log(Math.tan(Math.PI/4+u/2))-z)/C+q*Math.log(Math.tan(Math.PI/4+Math.asin(q*Math.sin(p))/2)),p=2*Math.atan(Math.exp(o))-Math.PI/2;var f=r(p);return[r(M),f]}();a.push(t[2]);var e,o=[(e=g(a))[0]+f,e[1]+l,e[2]+d],i=b(o);return t.length>2?i:i.slice(0,2)}var B={project:function(t){return a(t),h(T(t))},unproject:function(t){return a(t),G(u(t))}};var F={project:function(t){return a(t),M(T(t))},unproject:function(t){return a(t),G(p(t))}},N=t.bounds([42e4,3e4],[9e5,35e4]),k=t.bounds([242e4,103e4],[29e5,135e4]);function R(n,a){return{bounds:a,project:function(a){var e=a.lng,r=a.lat,o=n.project([e,r]),i=o[0],s=o[1];return t.point(i,s)},unproject:function(a){var e=a.x,r=a.y,o=n.unproject([e,r]),i=o[0],s=o[1];return t.latLng(s,i)}}}var Z=R(B,N),A=R(F,k),O=[4e3,3750,3500,3250,3e3,2750,2500,2250,2e3,1750,1500,1250,1e3,750,650,500,250,100,50,20,10,5,2.5,2,1.5,1,.5,.25,.1];var _=t.Class.extend({includes:t.CRS,initialize:function(n){this.code=n.code,this.projection=n.projection;var a=this.projection.bounds.getBottomLeft();this.transformation=new t.Transformation(1,-a.x,-1,a.y),this.infinite=!1},scale:function(t){return 1/function(t){if(t<0)return O[0];if(t>O.length-1)return O[O.length-1];var n=Math.floor(t);if(n===t)return O[t];var a=O[n],e=O[n+1]/a;return a*Math.pow(e,t-n)}(t)},zoom:function(t){return function(t){for(var n=-1,a=0;a<O.length;a+=1)if(t>=O[a]){n=a;break}if(0===n)return 0;if(-1===n)return O.length-1;if(O[n]===t)return n;var e=O[n-1],r=O[n];return n+Math.log(r/t)/Math.log(e/r)}(1/t)},distance:function(t,n){var a=this.project(t),e=this.project(n);return a.distanceTo(e)}}),D=new _({code:"EPSG:21781",projection:Z}),H=new _({code:"EPSG:2056",projection:A}),J=t.latLngBounds(H.unproject(H.projection.bounds.min),H.unproject(H.projection.bounds.max)),K=t.latLngBounds(H.unproject(t.point(2485e3,1075e3)),H.unproject(t.point(2835e3,1295e3))),Q={"EPSG:21781":"https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/21781/{z}/{y}/{x}.{format}","EPSG:2056":"https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/2056/{z}/{x}/{y}.{format}"};t.CRS.EPSG21781=D,t.CRS.EPSG2056=H;var U=t.TileLayer.extend({options:{attribution:'© <a href="https://www.swisstopo.ch/" target="_blank">Swisstopo</a>',bounds:J,crs:H,format:"jpeg",layer:"ch.swisstopo.pixelkarte-farbe",minZoom:14,maxNativeZoom:27,maxZoom:28,subdomains:"0123456789",switzerlandBounds:K,timestamp:"current"},initialize:function(n){t.setOptions(this,n);var a=this.options.url||Q[this.options.crs.code];t.TileLayer.prototype.initialize.call(this,a,this.options)}});return t.tileLayer.swiss=function(t){return new U(t)},U})); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("leaflet")):"function"==typeof define&&define.amd?define(["leaflet"],n):((t=t||self).L=t.L||{},t.L.TileLayer=t.L.TileLayer||{},t.L.TileLayer.Swiss=n(t.L))}(this,(function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;void 0===Number.isFinite&&(Number.isFinite=function(t){return"number"==typeof t&&isFinite(t)});var n=1e-12;function a(t){if(!Array.isArray(t))throw new Error("Expected input to be an array.");if(t.length<2)throw new Error("Expected input to be an array with length >= 2, got "+t.length+".");if(t.some((function(t){return!Number.isFinite(t)})))throw new Error("Expected all coordinates to be finite numbers.")}function e(t,n,a){return(a/60+n)/60+t}function o(t){return 180*t/Math.PI}function r(t){return t*Math.PI/180}function i(t,n){return{apply:function(a){var e=a[0],o=a[1],r=a.slice(2);return[e+t,o+n].concat(r)},unapply:function(a){var e=a[0],o=a[1],r=a.slice(2);return[e-t,o-n].concat(r)}}}var s=i(6e5,2e5),h=s.apply,u=s.unapply,c=i(26e5,12e5),M=c.apply,p=c.unapply,f=674.374,l=15.056,d=405.346;function m(t,a){var e=1/a,i=2*e-Math.pow(e,2);return{fromCartesian:function(a){for(var e,r,s,h=a[0],u=a[1],c=a[2],M=Math.atan(u/h),p=Math.sqrt(Math.pow(h,2)+Math.pow(u,2)),f=Math.atan(c/((1-i)*p));!(Math.abs(r-e)<n);)e=r,r=t/Math.sqrt(1-i*Math.pow(Math.sin(f),2)),s=p/Math.cos(f)-r,f=Math.atan(c/((1-i*r/(r+s))*p));var l=o(f);return[o(M),l,s]},toCartesian:function(n){var a=n[0],e=n[2];void 0===e&&(e=0);var o=r(n[1]),s=r(a),h=t/Math.sqrt(1-i*Math.pow(Math.sin(o),2));return[(h+e)*Math.cos(o)*Math.cos(s),(h+e)*Math.cos(o)*Math.sin(s),(h*(1-i)+e)*Math.sin(o)]}}}var w=m(6377397.155,299.15281285),v=w.fromCartesian,y=w.toCartesian,g=m(6378137,298.257223563),b=g.fromCartesian,j=g.toCartesian,x=1/299.15281285,L=r(e(46,57,8.66)),P=r(e(7,26,22.5)),S=2*x-Math.pow(x,2),E=6377397.155*Math.sqrt(1-S)/(1-S*Math.pow(Math.sin(L),2)),I=Math.sqrt(1+S/(1-S)*Math.pow(Math.cos(L),4)),C=Math.asin(Math.sin(L)/I),T=Math.sqrt(S),q=Math.log(Math.tan(Math.PI/4+C/2))-I*Math.log(Math.tan(Math.PI/4+L/2))+I*T/2*Math.log((1+T*Math.sin(L))/(1-T*Math.sin(L)));function z(t){var n,a,e,o,i,s,h,u,c,M=[(n=j(t))[0]-f,n[1]-l,n[2]-d],p=v(M),m=(a=p[0],e=r(p[1]),o=r(a),i=I*Math.log(Math.tan(Math.PI/4+e/2))-I*T/2*Math.log((1+T*Math.sin(e))/(1-T*Math.sin(e)))+q,s=2*(Math.atan(Math.exp(i))-Math.PI/4),h=I*(o-P),u=Math.asin(Math.cos(C)*Math.sin(s)-Math.sin(C)*Math.cos(s)*Math.cos(h)),c=Math.atan(Math.sin(h)/(Math.sin(C)*Math.tan(s)+Math.cos(C)*Math.cos(h))),[E*c,E/2*Math.log((1+Math.sin(u))/(1-Math.sin(u)))]);return t.length>2?m.concat([p[2]]):m}function B(t){var a=function(a){for(var e,r,i=t[0],s=2*(Math.atan(Math.exp(t[1]/E))-Math.PI/4),h=i/E,u=Math.asin(Math.cos(C)*Math.sin(s)+Math.sin(C)*Math.cos(s)*Math.cos(h)),c=Math.atan(Math.sin(h)/(Math.cos(C)*Math.cos(h)-Math.sin(C)*Math.tan(s))),M=P+c/I,p=u;!(Math.abs(r-e)<n);)e=r,r=(Math.log(Math.tan(Math.PI/4+u/2))-q)/I+T*Math.log(Math.tan(Math.PI/4+Math.asin(T*Math.sin(p))/2)),p=2*Math.atan(Math.exp(r))-Math.PI/2;var f=o(p);return[o(M),f]}();a.push(t[2]);var e,r=[(e=y(a))[0]+f,e[1]+l,e[2]+d],i=b(r);return t.length>2?i:i.slice(0,2)}var G={project:function(t){return a(t),h(z(t))},unproject:function(t){return a(t),B(u(t))}};var k={project:function(t){return a(t),M(z(t))},unproject:function(t){return a(t),B(p(t))}},F=t.bounds([42e4,3e4],[9e5,35e4]),N=t.bounds([242e4,103e4],[29e5,135e4]);function R(n,a){return{bounds:a,project:function(a){var e=a.lng,o=a.lat,r=n.project([e,o]),i=r[0],s=r[1];return t.point(i,s)},unproject:function(a){var e=a.x,o=a.y,r=n.unproject([e,o]),i=r[0],s=r[1];return t.latLng(s,i)}}}var Z=R(G,F),A=R(k,N),O=[4e3,3750,3500,3250,3e3,2750,2500,2250,2e3,1750,1500,1250,1e3,750,650,500,250,100,50,20,10,5,2.5,2,1.5,1,.5,.25,.1];var H=t.Class.extend({includes:t.CRS,initialize:function(n){this.code=n.code,this.projection=n.projection;var a=this.projection.bounds.getBottomLeft();this.transformation=new t.Transformation(1,-a.x,-1,a.y),this.infinite=!1},scale:function(t){return 1/function(t){if(t<0)return O[0];if(t>O.length-1)return O[O.length-1];var n=Math.floor(t);if(n===t)return O[t];var a=O[n],e=O[n+1]/a;return a*Math.pow(e,t-n)}(t)},zoom:function(t){return function(t){for(var n=-1,a=0;a<O.length;a+=1)if(t>=O[a]){n=a;break}if(0===n)return 0;if(-1===n)return O.length-1;if(O[n]===t)return n;var e=O[n-1],o=O[n];return n+Math.log(o/t)/Math.log(e/o)}(1/t)},distance:function(t,n){var a=this.project(t),e=this.project(n);return a.distanceTo(e)}}),_=new H({code:"EPSG:21781",projection:Z}),D=new H({code:"EPSG:2056",projection:A}),J=t.latLngBounds(D.unproject(D.projection.bounds.min),D.unproject(D.projection.bounds.max)),K=t.latLngBounds(D.unproject(t.point(2485e3,1075e3)),D.unproject(t.point(2835e3,1295e3))),Q={"EPSG:21781":"https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/21781/{z}/{y}/{x}.{format}","EPSG:2056":"https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/2056/{z}/{x}/{y}.{format}"},U=t.TileLayer.extend({options:{attribution:'© <a href="https://www.swisstopo.ch/" target="_blank">Swisstopo</a>',bounds:J,crs:D,format:"jpeg",layer:"ch.swisstopo.pixelkarte-farbe",minZoom:14,maxNativeZoom:27,maxZoom:28,subdomains:"0123456789",timestamp:"current"},initialize:function(n){t.setOptions(this,n);var a=this.options.url||Q[this.options.crs.code];t.TileLayer.prototype.initialize.call(this,a,this.options)}});return t.CRS.EPSG21781=_,t.CRS.EPSG2056=D,t.TileLayer.Swiss=U,t.tileLayer.swiss=function(t){return new U(t)},t.Map.addInitHook((function(){this.options.maxBounds||this.options.crs!==_&&this.options.crs!==D||this.setMaxBounds(J)})),t.Map.include({fitSwitzerland:function(){this.fitBounds(K)}}),U})); | ||
//# sourceMappingURL=Leaflet.TileLayer.Swiss.umd.js.map |
{ | ||
"name": "leaflet-tilelayer-swiss", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "Leaflet.TileLayer.Swiss is a Leaflet plugin for displaying national maps of Switzerland using map tiles from Swisstopo.", | ||
@@ -5,0 +5,0 @@ "source": "src/index.js", |
@@ -32,4 +32,4 @@ [![npm version](https://img.shields.io/npm/v/leaflet-tilelayer-swiss.svg)](https://www.npmjs.com/package/leaflet-tilelayer-swiss) | ||
```html | ||
<script src="https://unpkg.com/leaflet-tilelayer-swiss@2.0.2/dist/Leaflet.TileLayer.Swiss.umd.js" crossorigin | ||
integrity="sha384-RqGocB0JTU8Qswz8p4XRhx1rRTPnYiIHuvS9LQ2WqmR0IA3aj8t8WarEj/jalqsi"></script> | ||
<script src="https://unpkg.com/leaflet-tilelayer-swiss@2.0.3/dist/Leaflet.TileLayer.Swiss.umd.js" crossorigin | ||
integrity="sha384-bHBj6G7VG9PdK9RKiYRLB6PRJMpw8sRhZks+TGHAO3zgz8c9Z+lAaDmbv/zsQI3j"></script> | ||
``` | ||
@@ -61,7 +61,4 @@ | ||
// Limit map movement to layer bounds | ||
map.setMaxBounds(swissLayer.options.bounds) | ||
// Center the map on Switzerland | ||
map.fitBounds(swissLayer.options.switzerlandBounds); | ||
map.fitSwitzerland(); | ||
@@ -86,2 +83,5 @@ // Add a marker with a popup in Bern | ||
layer: 'ch.swisstopo.pixelkarte-farbe', | ||
// Minimum zoom. Levels below 14 exist for technical reasons, | ||
// but you probably do not want to use them. | ||
minZoom: 14, | ||
// Maximum zoom. Availability of zoom levels depends on the layer. | ||
@@ -88,0 +88,0 @@ maxNativeZoom: 27, |
import L from 'leaflet'; | ||
import { switzerlandBounds, tileBounds } from './bounds'; | ||
import { lv03, lv95 } from './crs'; | ||
import * as epsg from './epsg'; | ||
import SwissLayer from './layer'; | ||
const tileBounds = L.latLngBounds( | ||
lv95.unproject(lv95.projection.bounds.min), | ||
lv95.unproject(lv95.projection.bounds.max), | ||
); | ||
L.CRS.EPSG21781 = lv03; | ||
L.CRS.EPSG2056 = lv95; | ||
const switzerlandBounds = L.latLngBounds( | ||
lv95.unproject(L.point(2485000, 1075000)), | ||
lv95.unproject(L.point(2835000, 1295000)), | ||
); | ||
L.TileLayer.Swiss = SwissLayer; | ||
L.tileLayer.swiss = (options) => new SwissLayer(options); | ||
const urlsByCrs = { | ||
[epsg.lv03]: 'https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/21781/{z}/{y}/{x}.{format}', | ||
[epsg.lv95]: 'https://wmts{s}.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/2056/{z}/{x}/{y}.{format}', | ||
}; | ||
L.Map.addInitHook(function setMaxBounds() { | ||
if (!this.options.maxBounds) { | ||
if (this.options.crs === lv03 || this.options.crs === lv95) { | ||
// Limit map movement to area where tiles are available | ||
this.setMaxBounds(tileBounds); | ||
} | ||
} | ||
}); | ||
L.CRS.EPSG21781 = lv03; | ||
L.CRS.EPSG2056 = lv95; | ||
const Swiss = L.TileLayer.extend({ | ||
options: { | ||
attribution: '© <a href="https://www.swisstopo.ch/" target="_blank">Swisstopo</a>', | ||
bounds: tileBounds, | ||
crs: lv95, | ||
format: 'jpeg', | ||
layer: 'ch.swisstopo.pixelkarte-farbe', | ||
minZoom: 14, | ||
maxNativeZoom: 27, | ||
maxZoom: 28, | ||
subdomains: '0123456789', | ||
switzerlandBounds, | ||
timestamp: 'current', | ||
L.Map.include({ | ||
fitSwitzerland() { | ||
// Set the map view, such that the entire country is visible | ||
this.fitBounds(switzerlandBounds); | ||
}, | ||
initialize(options) { | ||
L.setOptions(this, options); | ||
const url = this.options.url || urlsByCrs[this.options.crs.code]; | ||
L.TileLayer.prototype.initialize.call(this, url, this.options); | ||
}, | ||
}); | ||
L.tileLayer.swiss = (options) => new Swiss(options); | ||
export default Swiss; | ||
export default SwissLayer; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88686
16
260