qd-changjing/public/leaflet/libs/mapbox-gl-js-enhance/mapbox-gl-enhance.js

48 lines
652 KiB
JavaScript
Raw Normal View History

2022-07-05 16:56:29 +08:00
/* Mapbox GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/mapbox/mapbox-gl-js/blob/v0.51.0/LICENSE.txt
* Copyright (c) 2016, Mapbox
* Copyright© 2000 - 2018 SuperMap Software Co. Ltd
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.mapboxgl = factory());
}(this, (function () { 'use strict';
/* eslint-disable */
var shared, worker, mapboxgl;
// define gets called three times: one for each chunk. we rely on the order
// they're imported to know which is which
function define(_, chunk) {
if (!shared) {
shared = chunk;
} else if (!worker) {
worker = chunk;
} else {
var workerBundleString = 'var sharedChunk = {}; (' + shared + ')(sharedChunk); (' + worker + ')(sharedChunk);'
var sharedChunk = {};
shared(sharedChunk);
mapboxgl = chunk(sharedChunk);
mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }));
}
}
define(["exports"],function(t){"use strict";function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r=n;function n(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=n,this.p2x=r,this.p2y=n;}n.prototype.sampleCurveX=function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},n.prototype.sampleCurveY=function(t){return ((this.ay*t+this.by)*t+this.cy)*t},n.prototype.sampleCurveDerivativeX=function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},n.prototype.solveCurveX=function(t,e){var r,n,i,a,o;for(void 0===e&&(e=1e-6),i=t,o=0;o<8;o++){if(a=this.sampleCurveX(i)-t,Math.abs(a)<e)return i;var s=this.sampleCurveDerivativeX(i);if(Math.abs(s)<1e-6)break;i-=a/s;}if((i=t)<(r=0))return r;if(i>(n=1))return n;for(;r<n;){if(a=this.sampleCurveX(i),Math.abs(a-t)<e)return i;t>a?r=i:n=i,i=.5*(n-r)+r;}return i},n.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var i=a;function a(t,e){this.x=t,this.y=e;}function o(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(var r=0;r<t.length;r++)if(!o(t[r],e[r]))return !1;return !0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return !1;if(Object.keys(t).length!==Object.keys(e).length)return !1;for(var n in t)if(!o(t[n],e[n]))return !1;return !0}return t===e}function s(t,e,n,i){var a=new r(t,e,n,i);return function(t){return a.solve(t)}}a.prototype={clone:function(){return new a(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=e*this.x-r*this.y,i=r*this.x+e*this.y;return this.x=n,this.y=i,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.x+r*(this.x-e.x)-n*(this.y-e.y),a=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=i,this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},a.convert=function(t){return t instanceof a?t:Array.isArray(t)?new a(t[0],t[1]):t};var u=s(.25,.1,.25,1);function p(t,e,r){return Math.min(r,Math.max(e,t))}function l(t,e,r){var n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function c(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];for(var n=0,i=e;n<i.length;n+=1){var a=i[n];for(var o in a)t[o]=a[o];}return t}var h=1;function f(){return h++}function y(){return function t(e){return e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}functi
define(["./shared.js"],function(e){"use strict";function t(e){var r=typeof e;if("number"===r||"boolean"===r||"string"===r||null==e)return JSON.stringify(e);if(Array.isArray(e)){for(var o="[",n=0,i=e;n<i.length;n+=1){o+=t(i[n])+",";}return o+"]"}for(var a=Object.keys(e).sort(),s="{",l=0;l<a.length;l++)s+=JSON.stringify(a[l])+":"+t(e[a[l]])+",";return s+"}"}function r(r){for(var o="",n=0,i=e.refProperties;n<i.length;n+=1){o+="/"+t(r[i[n]]);}return o}var o=function(e){e&&this.replace(e);};function n(e,t,r,o,n){if(void 0===t.segment)return !0;for(var i=t,a=t.segment+1,s=0;s>-r/2;){if(--a<0)return !1;s-=e[a].dist(i),i=e[a];}s+=e[a].dist(e[a+1]),a++;for(var l=[],u=0;s<r/2;){var c=e[a-1],h=e[a],f=e[a+1];if(!f)return !1;var p=c.angleTo(h)-h.angleTo(f);for(p=Math.abs((p+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:s,angleDelta:p}),u+=p;s-l[0].distance>o;)u-=l.shift().angleDelta;if(u>n)return !1;a++,s+=h.dist(f);}return !0}function i(e){for(var t=0,r=0;r<e.length-1;r++)t+=e[r].dist(e[r+1]);return t}function a(e,t,r){return e?.6*t*r:0}function s(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function l(t,r,o,l,u,c){for(var h=a(o,u,c),f=s(o,l)*c,p=0,d=i(t)/2,g=0;g<t.length-1;g++){var m=t[g],v=t[g+1],y=m.dist(v);if(p+y>d){var x=(d-p)/y,w=e.number(m.x,v.x,x),M=e.number(m.y,v.y,x),S=new e.Anchor(w,M,v.angleTo(m),g);return S._round(),!h||n(t,S,f,h,r)?S:void 0}p+=y;}}function u(t,r,o,l,u,c,h,f,p){var d=a(l,c,h),g=s(l,u),m=g*h,v=0===t[0].x||t[0].x===p||0===t[0].y||t[0].y===p;return r-m<r/4&&(r=m+r/4),function t(r,o,a,s,l,u,c,h,f){var p=u/2;var d=i(r);var g=0,m=o-a;var v=[];for(var y=0;y<r.length-1;y++){for(var x=r[y],w=r[y+1],M=x.dist(w),S=w.angleTo(x);m+a<g+M;){var P=((m+=a)-g)/M,b=e.number(x.x,w.x,P),_=e.number(x.y,w.y,P);if(b>=0&&b<f&&_>=0&&_<f&&m-p>=0&&m+p<=d){var T=new e.Anchor(b,_,S,y);T._round(),s&&!n(r,T,u,s,l)||v.push(T);}}g+=M;}h||v.length||c||(v=t(r,g/2,a,s,l,u,c,!0,f));return v}(t,v?r/2*f%r:(g/2+2*c)*h*f%r,r,d,o,m,v,!1,p)}o.prototype.replace=function(e){this._layerConfigs={},this._layers={},this.update(e,[]);},o.prototype.update=function(t,o){for(var n=this,i=0,a=t;i<a.length;i+=1){var s=a[i];n._layerConfigs[s.id]=s;var l=n._layers[s.id]=e.createStyleLayer(s);l._featureFilter=e.featureFilter(l.filter);}for(var u=0,c=o;u<c.length;u+=1){var h=c[u];delete n._layerConfigs[h],delete n._layers[h];}this.familiesBySource={};for(var f=0,p=function(e){for(var t={},o=0;o<e.length;o++){var n=r(e[o]),i=t[n];i||(i=t[n]=[]),i.push(e[o]);}var a=[];for(var s in t)a.push(t[s]);return a}(e.values(this._layerConfigs));f<p.length;f+=1){var d=p[f].map(function(e){return n._layers[e.id]}),g=d[0];if("none"!==g.visibility){var m=g.source||"",v=n.familiesBySource[m];v||(v=n.familiesBySource[m]={});var y=g.sourceLayer||"_geojsonTileLayer",x=v[y];x||(x=v[y]=[]),x.push(d);}}};var c=function(t,r,o,n,i,a,s,l,u,c,h,f){var p=s.top*l-u,d=s.bottom*l+u,g=s.left*l-u,m=s.right*l+u;if(this.boxStartIndex=t.length,c){var v=d-p,y=m-g;v>0&&(v=Math.max(10*l,v),this._addLineCollisionCircles(t,r,o,o.segment,y,v,n,i,a,h));}else{if(f){var x=new e.Point(g,p),w=new e.Point(m,p),M=new e.Point(g,d),S=new e.Point(m,d),P=f*Math.PI/180;x._rotate(P),w._rotate(P),M._rotate(P),S._rotate(P),g=Math.min(x.x,w.x,M.x,S.x),m=Math.max(x.x,w.x,M.x,S.x),p=Math.min(x.y,w.y,M.y,S.y),d=Math.max(x.y,w.y,M.y,S.y);}t.emplaceBack(o.x,o.y,g,p,m,d,n,i,a,0,0);}this.boxEndIndex=t.length;};c.prototype._addLineCollisionCircles=function(e,t,r,o,n,i,a,s,l,u){var c=i/2,h=Math.floor(n/c)||1,f=1+.4*Math.log(u)/Math.LN2,p=Math.floor(h*f/2),d=-i/2,g=r,m=o+1,v=d,y=-n/2,x=y-n/4;do{if(--m<0){if(v>y)return;m=0;break}v-=t[m].dist(g),g=t[m];}while(v>x);for(var w=t[m].dist(t[m+1]),M=-p;M<h+p;M++){var S=M*c,P=y+S;if(S<0&&(P+=S),S>n&&(P+=S-n),!(P<v)){for(;v+w<P;){if(v+=w,++m+1>=t.length)return;w=t[m].dist(t[m+1]);}var b=P-v,_=t[m],T=t[m+1].sub(_)._unit()._mult(b)._add(_)._round(),I=Math.abs(P-d)<c?0:.8*(P-d);e.emplaceBack(T.x,T.y,-i/2,-i/2,i/2,i/2,a,s,l,i/2,I);}}};var h=p,f=p;function p(e,t){if(!(this instanceof p))return new p(e,t);if(this.data=e||[],this.length=this.data.length,this.compare=t||d,this.
define(["./shared.js"],function(t){"use strict";var e=t.createCommonjsModule(function(t){function e(t){return !!("undefined"!=typeof window&&"undefined"!=typeof document&&Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray&&Function.prototype&&Function.prototype.bind&&Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions&&"JSON"in window&&"parse"in JSON&&"stringify"in JSON&&function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return !1;var t,e,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{e=new Worker(r),t=!0;}catch(e){t=!1;}e&&e.terminate();return URL.revokeObjectURL(r),t}()&&"Uint8ClampedArray"in window&&ArrayBuffer.isView&&function(t){void 0===i[t]&&(i[t]=function(t){var i=document.createElement("canvas"),r=Object.create(e.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,i.probablySupportsContext?i.probablySupportsContext("webgl",r)||i.probablySupportsContext("experimental-webgl",r):i.supportsContext?i.supportsContext("webgl",r)||i.supportsContext("experimental-webgl",r):i.getContext("webgl",r)||i.getContext("experimental-webgl",r)}(t));return i[t]}(t&&t.failIfMajorPerformanceCaveat))}t.exports?t.exports=e:window&&(window.mapboxgl=window.mapboxgl||{},window.mapboxgl.supported=e);var i={};e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};}),i={create:function(e,i,r){var o=t.window.document.createElement(e);return i&&(o.className=i),r&&r.appendChild(o),o},createNS:function(e,i){return t.window.document.createElementNS(e,i)}},r=t.window.document?t.window.document.documentElement.style:null;function o(t){if(!r)return null;for(var e=0;e<t.length;e++)if(t[e]in r)return t[e];return t[0]}var n,a=o(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]);i.disableDrag=function(){r&&a&&(n=r[a],r[a]="none");},i.enableDrag=function(){r&&a&&(r[a]=n);};var s=o(["transform","WebkitTransform"]);i.setTransform=function(t,e){t.style[s]=e;};var l=!1;try{var c=Object.defineProperty({},"passive",{get:function(){l=!0;}});t.window.addEventListener("test",c,c),t.window.removeEventListener("test",c,c);}catch(t){l=!1;}i.addEventListener=function(t,e,i,r){void 0===r&&(r={}),"passive"in r&&l?t.addEventListener(e,i,r):t.addEventListener(e,i,r.capture);},i.removeEventListener=function(t,e,i,r){void 0===r&&(r={}),"passive"in r&&l?t.removeEventListener(e,i,r):t.removeEventListener(e,i,r.capture);};var u=function(e){e.preventDefault(),e.stopPropagation(),t.window.removeEventListener("click",u,!0);};function h(e,i,r){var o,n,a,s=t.browser.devicePixelRatio>1?"@2x":"",l=t.getJSON(i(t.normalizeSpriteURL(e,s,".json"),t.ResourceType.SpriteJSON),function(t,e){l=null,a||(a=t,o=e,u());}),c=t.getImage(i(t.normalizeSpriteURL(e,s,".png"),t.ResourceType.SpriteImage),function(t,e){c=null,a||(a=t,n=e,u());});function u(){if(a)r(a);else if(o&&n){var e=t.browser.getImageData(n),i={};for(var s in o){var l=o[s],c=l.width,u=l.height,h=l.x,p=l.y,d=l.sdf,_=l.pixelRatio,f=new t.RGBAImage({width:c,height:u});t.RGBAImage.copy(e,f,{x:h,y:p},{x:0,y:0},{width:c,height:u}),i[s]={data:f,pixelRatio:_,sdf:d};}r(null,i);}}return {cancel:function(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null);}}}i.suppressClick=function(){t.window.addEventListener("click",u,!0),t.window.setTimeout(function(){t.window.removeEventListener("click",u,!0);},0);},i.mousePos=function(e,i){var r=e.getBoundingClientRect();return i=i.touches?i.touches[0]:i,new t.Point(i.clientX-r.left-e.clientLeft,i.clientY-r.top-e.clientTop)},i.touchPos=function(e,i){for(var r=e.getBoundingClientRect(),o=[],n="touchend"===i.type?i.changedTouches:i.touches,a=0;a<n.length;a++)o.push(new t.Point(n[a].clientX-r.left-e.clientLeft,n[a].clien
//
if (window) {
window.mapboxgl =mapboxgl;
}
return mapboxgl;
})));
//# sourceMappingURL=mapbox-gl.js.map