map/index.bundle.js

773 lines
988 KiB
JavaScript
Raw Normal View History

(function () {
'use strict';
const svg$5 = `
<svg viewBox="0 0 24 24" width="22" height="22" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fill-rule="evenodd">
<path d="M0 0h24v24H0z"/>
<path fill="#f44336" d="M12 3l4 8H8z"/>
<path fill="#9E9E9E" d="M12 21l-4-8h8z"/>
</g>
</svg>
`;
function iconPointer () {
return (new DOMParser().parseFromString(svg$5, 'image/svg+xml')).firstChild;
}
class Base {
constructor() {
this.node = document.createElement('div');
this.node.classList.add('mapboxgl-ctrl');
this.node.classList.add('mapboxgl-ctrl-group');
this.node.classList.add('mapbox-control');
}
addButton(button) {
this.node.appendChild(button.node);
}
addClassName(className) {
this.node.classList.add(className);
}
removeClassName(className) {
this.node.classList.remove(className);
}
onAddControl() {
// extend
}
onRemoveControl() {
// extend
}
onAdd(map) {
this.map = map;
this.onAddControl();
return this.node;
}
onRemove() {
this.onRemoveControl();
this.node.parentNode.removeChild(this.node);
this.map = undefined;
}
}
class Button {
constructor() {
this.node = document.createElement('button');
this.node.type = 'button';
this.icon = null;
}
setIcon(icon) {
this.icon = icon;
this.node.appendChild(icon);
}
setText(text) {
this.node.textContent = text;
}
onClick(callback) {
this.node.addEventListener('click', callback);
}
addClassName(className) {
this.node.classList.add(className);
}
removeClassName(className) {
this.node.classList.remove(className);
}
}
class CompassControl extends Base {
constructor(options) {
var _a;
super();
this.button = new Button();
this.instant = (_a = options === null || options === void 0 ? void 0 : options.instant) !== null && _a !== void 0 ? _a : true;
this.syncRotate = this.syncRotate.bind(this);
}
insert() {
this.addClassName('mapbox-compass');
if (!this.instant)
this.node.hidden = true;
this.button.setIcon(iconPointer());
this.button.onClick(() => {
this.map.easeTo({ bearing: 0, pitch: 0 });
});
this.addButton(this.button);
}
onAddControl() {
this.insert();
this.syncRotate();
this.map.on('rotate', this.syncRotate);
}
syncRotate() {
const angle = this.map.getBearing() * (-1);
if (!this.instant) {
this.node.hidden = angle === 0;
}
this.button.icon.style.transform = `rotate(${angle}deg)`;
}
}
var Cursor;
(function (Cursor) {
Cursor["Default"] = "";
Cursor["Move"] = "move";
Cursor["Grabbing"] = "grabbing";
Cursor["NESWResize"] = "nesw-resize";
Cursor["NWSEResize"] = "nwse-resize";
})(Cursor || (Cursor = {}));
var EditMode;
(function (EditMode) {
EditMode["Move"] = "move";
EditMode["Transform"] = "transform";
})(EditMode || (EditMode = {}));
var Visibility;
(function (Visibility) {
Visibility["Visible"] = "visible";
Visibility["None"] = "none";
})(Visibility || (Visibility = {}));
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var mapboxGl = {exports: {}};
/* Mapbox GL JS is Copyright © 2020 Mapbox and subject to the Mapbox Terms of Service ((https://www.mapbox.com/legal/tos/). */
(function (module, exports) {
(function (global, factory) {
module.exports = factory() ;
})(commonjsGlobal, (function () {
/* 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 = "self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; (" + shared + ")(sharedChunk); (" + worker + ")(sharedChunk); self.onerror = null;";
var sharedChunk = {};
shared(sharedChunk);
mapboxgl = chunk(sharedChunk);
if (typeof window !== 'undefined' && window && window.URL && window.URL.createObjectURL) {
mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }));
}
}
}
define(["exports"],(function(t){var e="undefined"!=typeof self?self:{},r="2.15.0";let n;const i={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==n){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{n=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):t;}catch(e){n=t;}}return n},get API_TILEJSON_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return /^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!i.API_URL)return null;try{const t=new URL(i.API_URL);return "api.mapbox.cn"===t.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===t.hostname?"https://events.mapbox.com/events/v2":null}catch(t){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},s={supported:!1,testSupport:function(t){!l&&o&&(u?c(t):a=t);}};let a,o,l=!1,u=!1;function c(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,o),t.isContextLost())return;s.supported=!0;}catch(t){}t.deleteTexture(e),l=!0;}e.document&&(o=e.document.createElement("img"),o.onload=function(){a&&c(a),a=null,u=!0;},o.onerror=function(){l=!0,a=null;},o.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const h="01";function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var d=f;function f(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=e,this.p2x=r,this.p2y=n;}f.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)<e)return r;var s=this.sampleCurveDerivativeX(r);if(Math.abs(s)<1e-6)break;r-=i/s;}var a=0,o=1;for(r=t,n=0;n<20&&(i=this.sampleCurveX(r),!(Math.abs(i-t)<e));n++)t>i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var y=p(d),m=g;function g(t,e){this.x=t,this.y=e;}g.prototype={clone:function(){return new g(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[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function Yh(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}Yh.Varint=0,Yh.Fixed64=1,Yh.Bytes=2,Yh.Fixed32=5;var Wh=4294967296,Qh=1/Wh,tp="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function ep(t){return t.type===Yh.Bytes?t.readVarint()+t.pos:t.pos+1}function rp(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function np(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function ip(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r]);}function sp(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r]);}function ap(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r]);}function op(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r]);}function lp(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r]);}function up(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r]);}function cp(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r]);}function hp(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r]);}function pp(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r]);}function dp(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function fp(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function yp(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}Yh.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),i=n>>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=dp(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=yp(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=dp(this.buf,this.pos)+dp(this.buf,this.pos+4)*Wh;return this.pos+=8,t},readSFixed64:function(){var t=dp(this.buf,this.pos)+yp(this.buf,this.pos+4)*Wh;return this.pos+=8,t},readFloat:function(){var t=Jh(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Jh(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return rp(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return rp(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return rp(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return rp(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return rp(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return rp(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&tp?function(t,e,r){return tp.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i<r;){var s,a,o,l=t[i],u=null,c=l>239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Yh.Bytes)return t.push(this.readVarint(e));var r=e
define(["./shared"],(function(e){function t(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let r="[";for(const o of e)r+=`${t(o)},`;return `${r}]`}let r="{";for(const o of Object.keys(e).sort())r+=`${o}:${t(e[o])},`;return `${r}}`}function r(r){let o="";for(const i of e.refProperties)o+=`/${t(r[i])}`;return o}class o{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,o){for(const r of t)this._layerConfigs[r.id]=r,(this._layers[r.id]=e.createStyleLayer(r)).compileFilter(),this.keyCache[r.id]&&delete this.keyCache[r.id];for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=function(e,t){const o={};for(let i=0;i<e.length;i++){const n=t&&t[e[i].id]||r(e[i]);t&&(t[e[i].id]=n);let s=o[n];s||(s=o[n]=[]),s.push(e[i]);}const i=[];for(const e in o)i.push(o[e]);return i}(e.values(this._layerConfigs),this.keyCache);for(const e of i){const t=e.map((e=>this._layers[e.id])),r=t[0];if("none"===r.visibility)continue;const o=r.source||"";let i=this.familiesBySource[o];i||(i=this.familiesBySource[o]={});const n=r.sourceLayer||"_geojsonTileLayer";let s=i[n];s||(s=i[n]=[]),s.push(t);}}}class i{loadTile(t,r){const{uid:o,encoding:i,rawImageData:n,padding:s,buildQuadTree:a}=t,l=e.window.ImageBitmap&&n instanceof e.window.ImageBitmap?this.getImageData(n,s):n;r(null,new e.DEMData(o,l,i,s<1,a));}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const r=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}function n(e,t){if(0!==e.length){s(e[0],t);for(var r=1;r<e.length;r++)s(e[r],!t);}}function s(e,t){for(var r=0,o=0,i=0,n=e.length,s=n-1;i<n;s=i++){var a=(e[i][0]-e[s][0])*(e[s][1]+e[i][1]),l=r+a;o+=Math.abs(r)>=Math.abs(a)?r-l+a:a-l+r,r=l;}r+o>=0!=!!t&&e.reverse();}var a=e.getDefaultExportFromCjs((function e(t,r){var o,i=t&&t.type;if("FeatureCollection"===i)for(o=0;o<t.features.length;o++)e(t.features[o],r);else if("GeometryCollection"===i)for(o=0;o<t.geometries.length;o++)e(t.geometries[o],r);else if("Feature"===i)e(t.geometry,r);else if("Polygon"===i)n(t.coordinates,r);else if("MultiPolygon"===i)for(o=0;o<t.coordinates.length;o++)n(t.coordinates[o],r);return t}));const l=e.VectorTileFeature.prototype.toGeoJSON;var u={exports:{}},h=e.pointGeometry,c=e.vectorTile.VectorTileFeature,f=p;function p(e,t){this.options=t||{},this.features=e,this.length=e.length;}function g(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096;}p.prototype.feature=function(e){return new g(this.features[e],this.options.extent)},g.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var t=0;t<e.length;t++){for(var r=e[t],o=[],i=0;i<r.length;i++)o.push(new h(r[i][0],r[i][1]));this.geometry.push(o);}return this.geometry},g.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var e=this.geometry,t=1/0,r=-1/0,o=1/0,i=-1/0,n=0;n<e.length;n++)for(var s=e[n],a=0;a<s.length;a++){var l=s[a];t=Math.min(t,l.x),r=Math.max(r,l.x),o=Math.min(o,l.y),i=Math.max(i,l.y);}return [t,o,r,i]},g.prototype.toGeoJSON=c.prototype.toGeoJSON;var d=e.pbf,m=f;function y(e){var t=new d;return function(e,t){for(var r in e.layers)t.writeMessage(3,v,e.layers[r]);}(e,t),t.finish()}function v(e,t){var r;t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);var o={keys:[],values:[],keycache:{},valuecache:{}};for(r=0;r<e.length;r++)o.feature=e.feature(r),t.writeMessage(2
define(["./shared"],(function(e){function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return !1;for(let o=0;o<e.length;o++)if(!t(e[o],i[o]))return !1;return !0}if("object"==typeof e&&null!==e&&null!==i){if("object"!=typeof i)return !1;if(Object.keys(e).length!==Object.keys(i).length)return !1;for(const o in e)if(!t(e[o],i[o]))return !1;return !0}return e===i}var i=o;function o(e){return !function(e){return "undefined"==typeof window||"undefined"==typeof document?"not a browser":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 e,t,i=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(i);try{t=new Worker(o),e=!0;}catch(t){e=!1;}return t&&t.terminate(),URL.revokeObjectURL(o),e}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return !1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===r[t=e&&e.failIfMajorPerformanceCaveat]&&(r[t]=function(e){var t,i=function(e){var t=document.createElement("canvas"),i=Object.create(o.webGLContextAttributes);return i.failIfMajorPerformanceCaveat=e,t.getContext("webgl",i)||t.getContext("experimental-webgl",i)}(e);if(!i)return !1;try{t=i.createShader(i.VERTEX_SHADER);}catch(e){return !1}return !(!t||i.isContextLost())&&(i.shaderSource(t,"void main() {}"),i.compileShader(t),!0===i.getShaderParameter(t,i.COMPILE_STATUS))}(t)),r[t]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var t;}(e)}var r={};function n(t,i,o){const r=e.window.document.createElement(t);return void 0!==i&&(r.className=i),o&&o.appendChild(r),r}function s(t,i,o){const r=e.window.document.createElementNS("http://www.w3.org/2000/svg",t);for(const e of Object.keys(i))r.setAttributeNS(null,e,i[e]);return o&&o.appendChild(r),r}o.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const a=e.window.document&&e.window.document.documentElement.style,l=a&&void 0!==a.userSelect?"userSelect":"WebkitUserSelect";let c;function h(){a&&l&&(c=a[l],a[l]="none");}function u(){a&&l&&(a[l]=c);}function _(t){t.preventDefault(),t.stopPropagation(),e.window.removeEventListener("click",_,!0);}function d(){e.window.addEventListener("click",_,!0),e.window.setTimeout((()=>{e.window.removeEventListener("click",_,!0);}),0);}function p(e,t){const i=e.getBoundingClientRect();return g(e,i,t)}function m(e,t){const i=e.getBoundingClientRect(),o=[];for(let r=0;r<t.length;r++)o.push(g(e,i,t[r]));return o}function f(t){return void 0!==e.window.InstallTrigger&&2===t.button&&t.ctrlKey&&e.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:t.button}function g(t,i,o){const r=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.Point((o.clientX-i.left)*r,(o.clientY-i.top)*r)}function v(e,t){var i=t[0],o=t[1],r=t[2],n=t[3],s=i*n-r*o;return s?(e[0]=n*(s=1/s),e[1]=-o*s,e[2]=-r*s,e[3]=i*s,e):null}function x(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class y extends e.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},t
//
// Our custom intro provides a specialized "define()" function, called by the
// AMD modules below, that sets up the worker blob URL and then executes the
// main module, storing its exported value as 'mapboxgl'
var mapboxgl$1 = mapboxgl;
return mapboxgl$1;
}));
} (mapboxGl));
(window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
const svg$4 = `
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#505050">
<path d="M14 7l-5 5 5 5V7z"/>
<path fill="none" d="M24 0v24H0V0h24z"/>
</svg>
`;
function iconLeft () {
return (new DOMParser().parseFromString(svg$4, 'image/svg+xml')).firstChild;
}
const svg$3 = `
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#505050">
<path d="M10 17l5-5-5-5v10z"/>
<path fill="none" d="M0 24V0h24v24H0z"/>
</svg>
`;
function iconRight () {
return (new DOMParser().parseFromString(svg$3, 'image/svg+xml')).firstChild;
}
var Direction;
(function (Direction) {
Direction["Next"] = "next";
Direction["Prev"] = "prev";
})(Direction || (Direction = {}));
function getData(feature) {
var _a;
const layerData = [
'layer',
{ key: 'id', value: feature.layer.id },
{ key: 'type', value: feature.layer.type },
{ key: 'source', value: feature.layer.source },
{ key: 'source-layer', value: (_a = feature.layer['source-layer']) !== null && _a !== void 0 ? _a : '—' },
];
const featureData = ['properties'];
if (feature.id) {
featureData.push({ key: '$id', value: feature.id });
}
Object.entries(feature.properties).forEach(([key, value]) => {
featureData.push({ key, value });
});
if (featureData.length === 1) {
featureData.pop(); // remove title if there are no properties
}
return [...layerData, ...featureData];
}
function popupTemplate(features) {
let current = 0;
const root = document.createElement('div');
root.classList.add('mapbox-control-inspect-popup');
const content = document.createElement('div');
content.classList.add('mapbox-control-inspect-content');
const templatePrev = () => {
const button = document.createElement('div');
button.setAttribute('type', 'button');
button.classList.add('mapbox-control-inspect-prev');
button.appendChild(iconLeft());
button.addEventListener('click', () => goTo(Direction.Prev));
return button;
};
const templateNext = () => {
const button = document.createElement('div');
button.setAttribute('type', 'button');
button.classList.add('mapbox-control-inspect-next');
button.appendChild((iconRight()));
button.addEventListener('click', () => goTo(Direction.Next));
return button;
};
const templateTitle = () => {
const title = document.createElement('div');
title.classList.add('mapbox-control-inspect-current');
title.textContent = `${current + 1} / ${features.length}`;
return title;
};
const templateHeader = () => {
const header = document.createElement('div');
header.classList.add('mapbox-control-inspect-header');
header.appendChild(templatePrev());
header.appendChild(templateTitle());
header.appendChild(templateNext());
return header;
};
const templateFeature = (feature) => {
const table = document.createElement('table');
table.classList.add('mapbox-control-inspect-grid');
const data = getData(feature);
data.forEach((record) => {
const row = document.createElement('tr');
if (typeof record === 'string') {
const caption = document.createElement('th');
caption.classList.add('mapbox-control-inspect-caption');
caption.colSpan = 2;
caption.textContent = record;
row.appendChild(caption);
table.append(row);
return;
}
const key = document.createElement('th');
const value = document.createElement('td');
key.classList.add('mapbox-control-inspect-key');
value.classList.add('mapbox-control-inspect-value');
key.textContent = record.key;
value.textContent = String(record.value);
row.appendChild(key);
row.appendChild(value);
table.append(row);
});
return table;
};
function goTo(dir) {
if (dir === Direction.Prev) {
current = current !== 0 ? current - 1 : features.length - 1;
}
else if (dir === Direction.Next) {
current = current !== features.length - 1 ? current + 1 : 0;
}
content.innerHTML = '';
content.appendChild(templateHeader());
content.appendChild(templateFeature(features[current]));
}
root.appendChild(content);
if (!features.length) {
content.textContent = 'No features';
}
else {
if (features.length > 1) {
content.appendChild(templateHeader());
}
content.appendChild(templateFeature(features[current]));
}
return root;
}
const svg$2 = `
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="#505050">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M20 19.59V8l-6-6H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c.45 0 .85-.15 1.19-.4l-4.43-4.43c-.8.52-1.74.83-2.76.83-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5c0 1.02-.31 1.96-.83 2.75L20 19.59zM9 13c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3z"/>
</svg>
`;
function iconInspect () {
return (new DOMParser().parseFromString(svg$2, 'image/svg+xml')).firstChild;
}
class InspectControl extends Base {
constructor(options) {
super();
this.console = options === null || options === void 0 ? void 0 : options.console;
this.popupNode = null;
this.lngLat = null;
this.isInspecting = false;
this.button = new Button();
}
insert() {
this.addClassName('mapbox-control-inspect');
this.button.setIcon(iconInspect());
this.button.onClick(() => {
if (this.isInspecting) {
this.inspectingOff();
}
else {
this.inspectingOn();
}
});
this.addButton(this.button);
this.mapClickListener = this.mapClickListener.bind(this);
this.updatePosition = this.updatePosition.bind(this);
}
inspectingOn() {
this.isInspecting = true;
this.button.addClassName('-active');
this.map.on('click', this.mapClickListener);
this.map.on('move', this.updatePosition);
this.map.getCanvas().style.cursor = 'pointer';
}
inspectingOff() {
this.isInspecting = false;
this.button.removeClassName('-active');
this.map.off('click', this.mapClickListener);
this.map.off('move', this.updatePosition);
this.map.getCanvas().style.cursor = '';
this.removePopup();
}
getFeatures(event) {
const selectThreshold = 3;
const queryBox = [
[event.point.x - selectThreshold, event.point.y + selectThreshold],
[event.point.x + selectThreshold, event.point.y - selectThreshold], // top right (NE)
];
return this.map.queryRenderedFeatures(queryBox);
}
addPopup(features) {
this.popupNode = popupTemplate(features);
this.mapContainer.appendChild(this.popupNode);
this.updatePosition();
if (this.console) {
console.log(features);
}
}
removePopup() {
if (!this.popupNode)
return;
this.mapContainer.removeChild(this.popupNode);
this.popupNode = null;
}
updatePosition() {
if (!this.lngLat)
return;
const canvasRect = this.mapCanvas.getBoundingClientRect();
const pos = this.map.project(this.lngLat);
this.popupNode.style.left = `${pos.x - canvasRect.left}px`;
this.popupNode.style.top = `${pos.y - canvasRect.top}px`;
}
mapClickListener(event) {
this.lngLat = event.lngLat;
const features = this.getFeatures(event);
this.removePopup();
this.addPopup(features);
}
onAddControl() {
this.mapContainer = this.map.getContainer();
this.mapCanvas = this.map.getCanvas();
this.insert();
}
onRemoveControl() {
this.inspectingOff();
}
}
class StylesControl extends Base {
constructor(options) {
var _a;
super();
this.styles = (_a = options === null || options === void 0 ? void 0 : options.styles) !== null && _a !== void 0 ? _a : this.defaultOptions;
this.onChange = options === null || options === void 0 ? void 0 : options.onChange;
this.buttons = [];
}
insert() {
this.addClassName('mapbox-control-styles');
this.styles.forEach((style) => {
const button = new Button();
button.setText(style.label);
button.onClick(() => {
if (button.node.classList.contains('-active'))
return;
this.map.setStyle(style.styleUrl);
if (this.onChange)
this.onChange(style);
});
this.buttons.push(button);
this.addButton(button);
});
this.map.on('styledata', () => {
this.buttons.forEach((button) => {
button.removeClassName('-active');
});
const styleNames = this.styles.map(style => style.styleName);
const currentStyleIndex = styleNames.indexOf(this.map.getStyle().name);
if (currentStyleIndex !== -1) {
const currentButton = this.buttons[currentStyleIndex];
currentButton.addClassName('-active');
}
});
}
get defaultOptions() {
return [
{
label: 'Streets',
styleName: 'Mapbox Streets',
styleUrl: 'mapbox://styles/mapbox/streets-v11',
}, {
label: 'Satellite',
styleName: 'Mapbox Satellite Streets',
styleUrl: 'mapbox://sprites/mapbox/satellite-streets-v11',
},
];
}
onAddControl() {
this.insert();
}
}
const svg$1 = `
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" viewBox="0 0 24 24" fill="#505050" width="20" height="20">
<rect fill="none" height="24" width="24"/>
<path d="M18,13h-5v5c0,0.55-0.45,1-1,1l0,0c-0.55,0-1-0.45-1-1v-5H6c-0.55,0-1-0.45-1-1l0,0c0-0.55,0.45-1,1-1h5V6 c0-0.55,0.45-1,1-1l0,0c0.55,0,1,0.45,1,1v5h5c0.55,0,1,0.45,1,1l0,0C19,12.55,18.55,13,18,13z"/>
</svg>
`;
function iconPlus () {
return (new DOMParser().parseFromString(svg$1, 'image/svg+xml')).firstChild;
}
const svg = `
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" viewBox="0 0 24 24" fill="#505050" width="20" height="20">
<rect fill="none" height="24" width="24"/>
<path d="M18,13H6c-0.55,0-1-0.45-1-1l0,0c0-0.55,0.45-1,1-1h12c0.55,0,1,0.45,1,1l0,0C19,12.55,18.55,13,18,13z"/>
</svg>
`;
function iconMinus () {
return (new DOMParser().parseFromString(svg, 'image/svg+xml')).firstChild;
}
class ZoomControl extends Base {
constructor() {
super();
this.zoomIn = new Button();
this.zoomOut = new Button();
}
insert() {
this.addClassName('mapbox-zoom');
this.zoomIn.setIcon(iconPlus());
this.zoomIn.onClick(() => this.map.zoomIn());
this.zoomOut.setIcon(iconMinus());
this.zoomOut.onClick(() => this.map.zoomOut());
this.addButton(this.zoomIn);
this.addButton(this.zoomOut);
}
onAddControl() {
this.insert();
}
}
function loginfo(...str) {
let info = str.shift();
console.log(
`%c ${info} `,
"color:white; background-color: #78d6fa; border-radius:10px;",
...str,
);
}
window.onload = async () => {
const params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
});
const projection = params.projection || "globe";
const mapId = params.id || "worldMap";
let mapDataFromId = (
await (
await fetch(
`https://raw.githubusercontent.com/CIMEngine/MapList/main/index.json`,
)
).json()
)[mapId];
const geoURL = params.geoURL || mapDataFromId.geoURL;
const countryInfoUrl = params.countryInfoURL || mapDataFromId.countryInfoURL;
const debug = params.debug || false;
mapboxgl.accessToken =
"pk.eyJ1IjoiYXJ0ZWdvc2VyIiwiYSI6ImNrcDViN3BhcDAwbW0ydnBnOXZ0ZzFreXUifQ.FIVtaBNr9dr_TIw672Zqdw";
let map = new mapboxgl.Map({
container: "map",
style: "mapbox://styles/artegoser/clfm612fg002601nlcika2018?optimize=true",
center: [53.19, 41.28],
zoom: 3,
projection: projection,
});
map.addControl(
new StylesControl({
styles: [
{
label: "Streets",
styleName: "Mapbox Streets",
styleUrl:
"mapbox://styles/artegoser/clfm612fg002601nlcika2018?optimize=true",
},
{
label: "Satellite",
styleName: "Satellite",
styleUrl:
"mapbox://styles/artegoser/cliskjlhw00ug01pgfs9lesog?optimize=true",
},
],
}),
"top-left",
);
map.addControl(new ZoomControl(), "top-right");
map.addControl(new CompassControl(), "top-right");
map.addControl(
new MapboxExportControl({
PageSize: Size.A3,
PageOrientation: PageOrientation.Portrait,
Format: Format.PNG,
DPI: DPI[96],
Crosshair: true,
PrintableArea: true,
}),
"top-right",
);
if (debug) {
map.addControl(new InspectControl(), "bottom-right");
}
let converter = new showdown.Converter();
map.on("style.load", async () => {
map.loadImage(
"https://cimengine.github.io/map/icons/city.png",
(error, image) => {
if (error) throw error;
map.addImage("city", image);
},
);
map.loadImage(
"https://cimengine.github.io/map/icons/capital.png",
(error, image) => {
if (error) throw error;
map.addImage("capital-city", image);
map.addImage("capital", image);
},
);
map.loadImage(
"https://cimengine.github.io/map/icons/landmark.png",
(error, image) => {
if (error) throw error;
map.addImage("landmark-0", image);
},
);
let lasticocords;
loginfo("Getting country data");
let coarray = await fetch(countryInfoUrl);
coarray = await coarray.json();
let countries = {};
for (let i = 0; i < coarray.length; i++)
countries[coarray[i].idc] = coarray[i];
map.addSource("map-data", {
type: "geojson",
data: geoURL,
});
map.addLayer({
id: "map-data-fill-outline",
type: "line",
source: "map-data",
paint: {
"line-color": ["coalesce", ["get", "stroke"], "#0c7700"],
"line-width": 2,
"line-opacity": 0.8,
},
});
map.addLayer({
id: "map-data-fill",
type: "fill",
source: "map-data",
paint: {
"fill-color": ["get", "fill"],
"fill-opacity": ["coalesce", ["get", "fill-opacity"], 0.3],
},
});
map.addLayer({
id: "map-data-symbol",
type: "symbol",
source: "map-data",
layout: {
"icon-image": ["get", "type"],
"icon-size": 0.15,
},
minzoom: 3,
});
map.on("click", "map-data-fill", (e) => {
const coordinates = e.lngLat;
while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;
}
onEachFeature(e.features[0], coordinates);
});
map.on("click", "map-data-symbol", (e) => {
const coordinates = e.lngLat;
while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;
}
onEachFeature(e.features[0], coordinates);
});
function onEachFeature(feature, coordinates) {
if (feature.geometry.type === "Point") {
lasticocords = coordinates;
return new mapboxgl.Popup()
.setLngLat(coordinates)
.setHTML(
`
${feature?.properties?.amount
? `<div class="row glass" style="color: "white";"><div class="col">Population - ${feature.properties.amount} people.</div></div>`
: ""
}
<div class="row" style="padding: 5px;">
${feature?.properties?.img
? `<div class="col-md-12 col-sm-12" style="padding: 0px;"><img class="w-100 about-img" src="${feature.properties.img}" alt="${feature.properties.name} img"></div>`
: ""
}
<div class="col-md-12 col-sm-12 text-center glass mb-2">
<h5 className="card-title">${feature.properties.name}
${feature.properties.name_ru
? ` - ${feature.properties.name_ru}`
: ""
}
</h5>
</div>
${feature.properties.description
? `<div class="col-md-12 col-sm-12 text-center glass"><div>${converter.makeHtml(
feature.properties.description,
)}</div></div>`
: ""
}
</div>
`,
)
.addTo(map);
} else if (
feature.geometry.type === "Polygon" ||
feature.geometry.type === "MultiPolygon"
) {
let country = countries[feature.properties.name] || {
name: "gl js mapbox is awesome",
};
setTimeout(() => {
if (country.name !== "gl js mapbox is awesome")
if (lasticocords !== coordinates)
return new mapboxgl.Popup()
.setLngLat(coordinates)
.setHTML(
`
<div class="row" style="padding: 5px;">
<div class="col-12 col-sm-12" style="padding: 0px;">
<img class="w-100 about-img" src="${country.img
}">
</div>
<div class="col-12 text-center glass">
<h5>
${country.name}
</h5>
</div>
<div class="col-12 text-center glass">
${JSON.parse(
feature.properties.tags || "[]",
).join(", ")}
</div>
<div class="col-12 text-center glass">
Founding date: ${country.date}
</div>
<div class="col-md-12 col-sm-12 text-center glass">
${country.description
? `<div>${converter.makeHtml(
country.description,
)}</div>`
: ""
}
</div>
<div class="col-12 text-center glass">
Area: ${feature.properties.area} km²
</div>
<div class="col-12 text-center mt-2">
${country.about
? `<a href="${country.about}" class="about">About</a>`
: ""
}
</div>
</div>`,
)
.addTo(map);
}, 1);
}
}
});
};
})();
//# sourceMappingURL=index.bundle.js.map