@nextgis/webmap
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -35,5 +35,5 @@ import { MapClickEvent } from './MapAdapter'; | ||
export interface StarterKit { | ||
getSettings?(): Promise<AppSettings | false>; | ||
getSettings?(webMap?: WebMap): Promise<AppSettings | false>; | ||
getLayerAdapters?(): Promise<any>; | ||
onMapClick?(evt: MapClickEvent, webMap?: WebMap): any; | ||
} |
import { GeoJsonObject } from 'geojson'; | ||
import { LatLng } from './BaseTypes'; | ||
interface AdapterOptions { | ||
export interface AdapterOptions { | ||
id?: string; | ||
@@ -41,2 +41,1 @@ url?: string; | ||
} | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("events")):"function"==typeof define&&define.amd?define(["events"],e):"object"==typeof exports?exports.WebMap=e(require("events")):t.WebMap=e(t.events)}(window,function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(e,n){e.exports=t},function(t,e,n){"use strict";n.r(e);Object.prototype.toString;var r=n(0);function i(t,e,n,r){var o;if(void 0===e&&(e=function(t){return t}),void 0===r&&(r=[]),Array.isArray(t))o=t;else{e(t)&&r.push(t);var s=n(t);s&&(o=[].concat(s))}if(o)for(var a=0;a<o.length;a++)o[a]&&i(o[a],e,n,r);return r}var o=function(){function t(t){this._children=[],this.entry=t}return t.prototype.setParent=function(t){this._parent=t},t.prototype.addChildren=function(t){this._children.push(t)},t.prototype.getParent=function(){return this._parent},t.prototype.getParents=function(t){return this.getParent()?i(this._parent,t,function(t){return t.tree.getParent()}):[]},t.prototype.getDescendants=function(t){return i(this._children,t,function(t){return t.tree.getChildren()})},t.prototype.getChildren=function(){return this._children},t}(),s=function(){function t(t,e,n){this.emitter=new r.EventEmitter,this.entry=e,this.options=Object.assign({},n),this.name=t,this._value=this.getProperty()}return t.prototype.getProperty=function(){return"function"==typeof this.options.getProperty?this.options.getProperty.call(this):this.options.value},t.prototype.getParents=function(){return this.entry.tree.getParents()||[]},t.prototype.getParent=function(){return this.entry.tree.getParent()},t.prototype.isGroup=function(){return this.entry.tree.getDescendants().length},t.prototype.isBlocked=function(){var t=this;if(void 0===this._blocked){var e=this.entry.tree.getParents();if(e){var n=e.find(function(e){var n=e.properties.get(t.name);if(n)return!n.value()});this._blocked=!!n}else this._blocked=!1}return this._blocked},t.prototype.set=function(t,e){this._value=this._prepareValue(t),this.update(this._value,e),this._fireChangeEvent(this._value,e)},t.prototype.value=function(){return this.getValue()},t.prototype.update=function(t,e){this._callOnSet(t,e)},t.prototype.getContainer=function(){return this._container},t.prototype.destroy=function(){this._container&&this._container.parentNode.removeChild(this._container),this._removeEventsListener&&this._removeEventsListener()},t.prototype.getValue=function(){return void 0!==this._value?this._value:this.getProperty()},t.prototype._prepareValue=function(t){return t},t.prototype._callOnSet=function(t,e){this.options.onSet&&this.options.onSet.call(this,t,e)},t.prototype._fireChangeEvent=function(t,e){var n=this;t=void 0!==t?t:this.getValue(),this.emitter.emit("change",{value:t,options:e}),this.entry.tree.getParents().forEach(function(r){var i=r.properties.get(n.name);i&&i.emitter.emit("change-tree",{value:t,options:e,entry:n.entry})})},t}(),a=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},p=function(t){function e(n,r,i){var o=t.call(this,n,r,Object.assign({},e.options,i))||this;return o.set(o.value()),o}return a(e,t),e.prototype.update=function(t,e){if(t){if(e&&e.bubble||this.options.bubble){this.unBlock(e);var n=this.getParent(),r=n&&n.properties.get(this.name);r&&r.set(t,Object.assign({},e,{bubble:!0,propagation:!1}))}this.isBlocked()||this._turnOn(e)}else this._turnOff(e);(e&&e.propagation||this.options.propagation)&&this._propagation(t,e)},e.prototype.getHierarchyValue=function(){var t=this;return this.value()&&this.getParents().every(function(e){var n=e.properties[t.name];return n&&n.get()})},e.prototype._prepareValue=function(t){return!!t},e.prototype._turnOff=function(t){this.options.turnOff&&this.options.turnOff.call(this,t),this._callOnSet(!1,t),this.options.hierarchy&&this.isGroup()&&this.blockChilds(t)},e.prototype._turnOn=function(t){this.options.turnOn&&this.options.turnOn.call(this,t),this._callOnSet(!0,t),this.options.hierarchy&&this.isGroup()&&this.unblockChilds(t)},e.prototype.block=function(t){this._blocked=!0,this._block(t)},e.prototype._block=function(t){this._turnOff(t)},e.prototype.unBlock=function(t){this._blocked=!1,this.getValue()&&this._unBlock(t)},e.prototype._unBlock=function(t){this._turnOn(t)},e.prototype.blockChilds=function(t){this.entry.tree.getDescendants().forEach(this._blockChild.bind(this,t))},e.prototype.unblockChilds=function(t){this.entry.tree.getChildren().forEach(this._unBlockChild.bind(this,t))},e.prototype._blockChild=function(t,e){var n=e.properties.get(this.name);n.block&&n.block(t)},e.prototype._unBlockChild=function(t,e){var n=e.properties.get(this.name);n.unBlock&&n.unBlock(t)},e.prototype._propagation=function(t,e){if(this.isGroup())for(var n=this.entry.tree.getChildren(),r=0;r<n.length;r++){var i=n[r].properties.get(this.name);i&&i.set(t,u({},e,{propagation:!0,bubble:!1}))}},e.options={hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"},e}(s),h=function(){return(h=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},c=function(){function t(t,e){this.options={},this.entry=t,this._properties={},this._propertiesList=[],e&&e.forEach(this._setPropertyHandler.bind(this))}return t.prototype.add=function(t){this._setPropertyHandler(t)},t.prototype._setPropertyHandler=function(e){var n=t.handlers,r=e.handler;if(!r&&e.type)switch(e.type){case"boolean":r=n.CheckProperty;break;case"string":r=n.BaseProperty;break;default:r=n.BaseProperty}if(r){var i=h({},e||{});this._properties[e.name]=new r(e.name,this.entry,i),this._propertiesList.push(e.name)}},t.prototype.update=function(){this.list().forEach(function(t){t.update()})},t.prototype.value=function(t){var e=this.get(t);if(e)return e.value},t.prototype.set=function(t,e,n){var r=this.get(t);if(r)return r.set(e,n)},t.prototype.get=function(t){return this._properties[t]},t.prototype.list=function(){var t=this;return this._propertiesList.map(function(e){return t._properties[e]})},t.prototype.destroy=function(){for(var t in this._properties)if(this._properties.hasOwnProperty(t)){var e=this.get(t);e&&e.destroy&&e.destroy()}this._properties=null,this._propertiesList=[]},t.handlers={CheckProperty:p},t}(),l=0,f=function(){function t(t){this.emitter=new r.EventEmitter,this.options=Object.assign({},this.options,t),this.id=String(l++),this.tree=new o(this)}return t.prototype.initProperties=function(){this.properties=new c(this,this.options.properties)},t}(),y=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),d=function(t){function e(n,r,i,o){var s=t.call(this,Object.assign({},e.options,i))||this;return s.map=n,s.item=r,o&&s.tree.setParent(o),s.initProperties(),s.initItem(r),s}return y(e,t),e.prototype.initItem=function(t){var n=this,r=t._layer;if("group"===t.item_type||"root"===t.item_type)t.children&&t.children.length&&t.children.forEach(function(t){var r=new e(n.map,t,n.options,n);n.tree.addChildren(r)});else if("layer"===t.item_type){var i=t.layer_adapter.toUpperCase();r=this.map.addLayer(i,Object.assign({id:this.id},t))}r&&(t._layer=r,"layer"===t.item_type&&t.layer_enabled&&this.properties.get("visibility").set(!0))},e.prototype.fit=function(){"layer"===this.item.item_type&&console.log(this.item)},e.options={properties:[{type:"boolean",name:"visibility",getProperty:function(){var t=this.entry;return"group"===t.item.item_type||("layer"===t.item.item_type?t.item.layer_enabled:"root"===t.item.item_type)},onSet:function(t){var e=this.entry;"layer"===e.item.item_type&&(t?e.map.showLayer(e.id):e.map.hideLayer(e.id),e.item.layer_enabled=t)}}]},e}(f),_=function(){return function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222}}(),v=function(){function t(){this.keyCodeAlias=new _,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];if(e)return this.keys[e]},t.prototype.addKeyboardEventsListener=function(){window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1)},t.prototype.removeKeyboardEventsListener=function(){window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1)},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}();n.d(e,"WebLayerEntry",function(){return d});var b=function(){return(b=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},g=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):new n(function(e){e(t.value)}).then(s,a)}u((r=r.apply(t,e||[])).next())})},m=function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},w=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise(function(r,i){(function(t,e,n,r){Promise.resolve(r).then(function(e){t({value:e,done:n})},e)})(r,i,(e=t[n](e)).done,e.value)})}}},k=function(){function t(t){this.displayProjection="EPSG:3857",this.lonlatProjection="EPSG:4326",this.emitter=new r.EventEmitter,this.keys=new v,this.settingsIsLoading=!1,this._baseLayers=[],this.map=t.mapAdapter,this._starterKits=t.starterKits||[],this._addEventsListeners()}return t.prototype.create=function(t){return g(this,void 0,void 0,function(){return m(this,function(e){switch(e.label){case 0:return this.options=function t(e,n,r){void 0===r&&(r=!1);var i=Array.isArray(n),o=i&&[]||{};return i?r?(e=e||[],o=o.concat(e),n.forEach(function(n,i){void 0===o[i]?o[i]=n:"object"==typeof n?o[i]=t(e[i],n,r):-1===e.indexOf(n)&&o.push(n)})):o=n:(e&&"object"==typeof e&&Object.keys(e).forEach(function(t){o[t]=e[t]}),Object.keys(n).forEach(function(i){"object"==typeof n[i]&&n[i]&&e[i]?o[i]=t(e[i],n[i],r):o[i]=n[i]})),o}(this.options||{},t),this.settings||!this._starterKits.length?[3,2]:[4,this.getSettings()];case 1:e.sent(),e.label=2;case 2:return[4,this._setupMap()];case 3:return e.sent(),[2,this]}})})},t.prototype.getSettings=function(){return g(this,void 0,void 0,function(){var t,e,n,r,i,o,s=this;return m(this,function(a){switch(a.label){case 0:return this.settings?[2,Promise.resolve(this.settings)]:this.settingsIsLoading?[2,new Promise(function(t){var e=function(n){t(n),s.emitter.removeListener("load-settings",e)};s.emitter.on("load-settings",e)})]:[3,1];case 1:this.settingsIsLoading=!0,t=void 0,a.label=2;case 2:a.trys.push([2,7,,8]),t={},e=0,n=this._starterKits.filter(function(t){return t.getSettings}),a.label=3;case 3:return e<n.length?[4,(r=n[e]).getSettings.call(r)]:[3,6];case 4:(i=a.sent())&&Object.assign(t,i),a.label=5;case 5:return e++,[3,3];case 6:return[3,8];case 7:throw o=a.sent(),this.settingsIsLoading=!1,new Error(o);case 8:if(t)return this.settings=t,this.settingsIsLoading=!1,this.emitter.emit("load-settings",t),[2,t];a.label=9;case 9:return[2]}})})},t.prototype.addBaseLayer=function(t,e,n){var r=this;return this.map.addLayer(e,b({},n,{id:t}),!0).then(function(t){return t&&r._baseLayers.push(t.name),t})},t.prototype.isBaseLayer=function(t){return-1!==this._baseLayers.indexOf(t)},t.prototype._setupMap=function(){return g(this,void 0,void 0,function(){var t,e,n,r,i,o;return m(this,function(s){switch(s.label){case 0:return this.settings&&(t=this.settings,e=t.extent_bottom,n=t.extent_left,r=t.extent_top,i=t.extent_right,e&&n&&r&&i&&(this._extent=[n,e,i,r],(o=this._extent)[3]>82&&(o[3]=82),o[1]<-82&&(o[1]=-82))),this.map.displayProjection=this.displayProjection,this.map.lonlatProjection=this.lonlatProjection,this.map.create(this.options),this._addTreeLayers(),[4,this._addLayerProviders()];case 1:return s.sent(),this._zoomToInitialExtent(),this.emitter.emit("build-map",this.map),[2,this]}})})},t.prototype._addTreeLayers=function(){return g(this,void 0,void 0,function(){var t,e;return m(this,function(n){switch(n.label){case 0:return[4,this.getSettings()];case 1:return(t=n.sent())&&(e=t.root_item)&&(this.layers=new d(this.map,e),this.emitter.emit("add-layers",this.layers)),[2]}})})},t.prototype._zoomToInitialExtent=function(){if(this._extent)this.map.fit(this._extent);else{var t=this.options,e=t.center,n=t.zoom;e&&this.map.setCenter(e),n&&this.map.setZoom(n)}},t.prototype._addLayerProviders=function(){return g(this,void 0,void 0,function(){var t,e,n,r,i,o,s,a,u,p,h,c,l,f,y;return m(this,function(d){switch(d.label){case 0:d.trys.push([0,26,,27]),d.label=1;case 1:d.trys.push([1,19,20,25]),i=w(this._starterKits.filter(function(t){return t.getLayerAdapters})),d.label=2;case 2:return[4,i.next()];case 3:return(o=d.sent()).done?[3,18]:[4,(s=o.value).getLayerAdapters.call(s)];case 4:if(!(a=d.sent()))return[3,17];d.label=5;case 5:d.trys.push([5,11,12,17]),u=w(a),d.label=6;case 6:return[4,u.next()];case 7:return(p=d.sent()).done?[3,10]:[4,(h=p.value).createAdapter(this.map)];case 8:(c=d.sent())&&(this.map.layerAdapters[h.name]=c),d.label=9;case 9:return[3,6];case 10:return[3,17];case 11:return l=d.sent(),n={error:l},[3,17];case 12:return d.trys.push([12,,15,16]),p&&!p.done&&(r=u.return)?[4,r.call(u)]:[3,14];case 13:d.sent(),d.label=14;case 14:return[3,16];case 15:if(n)throw n.error;return[7];case 16:return[7];case 17:return[3,2];case 18:return[3,25];case 19:return f=d.sent(),t={error:f},[3,25];case 20:return d.trys.push([20,,23,24]),o&&!o.done&&(e=i.return)?[4,e.call(i)]:[3,22];case 21:d.sent(),d.label=22;case 22:return[3,24];case 23:if(t)throw t.error;return[7];case 24:return[7];case 25:return[3,27];case 26:throw y=d.sent(),new Error(y);case 27:return[2]}})})},t.prototype._addEventsListeners=function(){var t=this;this.map.emitter.on("click",function(e){return t._onMapClick(e)})},t.prototype._onMapClick=function(t){var e=this;this.emitter.emit("click",t),this._starterKits.forEach(function(n){n.onMapClick&&n.onMapClick(t,e)})},t}();e.default=k}]).default}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("events")):"function"==typeof define&&define.amd?define(["events"],e):"object"==typeof exports?exports.WebMap=e(require("events")):t.WebMap=e(t.events)}(window,function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(e,n){e.exports=t},function(t,e,n){"use strict";n.r(e);Object.prototype.toString;var r=n(0);function i(t,e,n,r){var o;if(void 0===e&&(e=function(t){return t}),void 0===r&&(r=[]),Array.isArray(t))o=t;else{e(t)&&r.push(t);var s=n(t);s&&(o=[].concat(s))}if(o)for(var a=0;a<o.length;a++)o[a]&&i(o[a],e,n,r);return r}var o=function(){function t(t){this._children=[],this.entry=t}return t.prototype.setParent=function(t){this._parent=t},t.prototype.addChildren=function(t){this._children.push(t)},t.prototype.getParent=function(){return this._parent},t.prototype.getParents=function(t){return this.getParent()?i(this._parent,t,function(t){return t.tree.getParent()}):[]},t.prototype.getDescendants=function(t){return i(this._children,t,function(t){return t.tree.getChildren()})},t.prototype.getChildren=function(){return this._children},t}(),s=function(){function t(t,e,n){this.emitter=new r.EventEmitter,this.entry=e,this.options=Object.assign({},n),this.name=t,this._value=this.getProperty()}return t.prototype.getProperty=function(){return"function"==typeof this.options.getProperty?this.options.getProperty.call(this):this.options.value},t.prototype.getParents=function(){return this.entry.tree.getParents()||[]},t.prototype.getParent=function(){return this.entry.tree.getParent()},t.prototype.isGroup=function(){return this.entry.tree.getDescendants().length},t.prototype.isBlocked=function(){var t=this;if(void 0===this._blocked){var e=this.entry.tree.getParents();if(e){var n=e.find(function(e){var n=e.properties.get(t.name);if(n)return!n.value()});this._blocked=!!n}else this._blocked=!1}return this._blocked},t.prototype.set=function(t,e){this._value=this._prepareValue(t),this.update(this._value,e),this._fireChangeEvent(this._value,e)},t.prototype.value=function(){return this.getValue()},t.prototype.update=function(t,e){this._callOnSet(t,e)},t.prototype.getContainer=function(){return this._container},t.prototype.destroy=function(){this._container&&this._container.parentNode.removeChild(this._container),this._removeEventsListener&&this._removeEventsListener()},t.prototype.getValue=function(){return void 0!==this._value?this._value:this.getProperty()},t.prototype._prepareValue=function(t){return t},t.prototype._callOnSet=function(t,e){this.options.onSet&&this.options.onSet.call(this,t,e)},t.prototype._fireChangeEvent=function(t,e){var n=this;t=void 0!==t?t:this.getValue(),this.emitter.emit("change",{value:t,options:e}),this.entry.tree.getParents().forEach(function(r){var i=r.properties.get(n.name);i&&i.emitter.emit("change-tree",{value:t,options:e,entry:n.entry})})},t}(),a=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},p=function(t){function e(n,r,i){var o=t.call(this,n,r,Object.assign({},e.options,i))||this;return o.set(o.value()),o}return a(e,t),e.prototype.update=function(t,e){if(t){if(e&&e.bubble||this.options.bubble){this.unBlock(e);var n=this.getParent(),r=n&&n.properties.get(this.name);r&&r.set(t,Object.assign({},e,{bubble:!0,propagation:!1}))}this.isBlocked()||this._turnOn(e)}else this._turnOff(e);(e&&e.propagation||this.options.propagation)&&this._propagation(t,e)},e.prototype.getHierarchyValue=function(){var t=this;return this.value()&&this.getParents().every(function(e){var n=e.properties[t.name];return n&&n.get()})},e.prototype._prepareValue=function(t){return!!t},e.prototype._turnOff=function(t){this.options.turnOff&&this.options.turnOff.call(this,t),this._callOnSet(!1,t),this.options.hierarchy&&this.isGroup()&&this.blockChilds(t)},e.prototype._turnOn=function(t){this.options.turnOn&&this.options.turnOn.call(this,t),this._callOnSet(!0,t),this.options.hierarchy&&this.isGroup()&&this.unblockChilds(t)},e.prototype.block=function(t){this._blocked=!0,this._block(t)},e.prototype._block=function(t){this._turnOff(t)},e.prototype.unBlock=function(t){this._blocked=!1,this.getValue()&&this._unBlock(t)},e.prototype._unBlock=function(t){this._turnOn(t)},e.prototype.blockChilds=function(t){this.entry.tree.getDescendants().forEach(this._blockChild.bind(this,t))},e.prototype.unblockChilds=function(t){this.entry.tree.getChildren().forEach(this._unBlockChild.bind(this,t))},e.prototype._blockChild=function(t,e){var n=e.properties.get(this.name);n.block&&n.block(t)},e.prototype._unBlockChild=function(t,e){var n=e.properties.get(this.name);n.unBlock&&n.unBlock(t)},e.prototype._propagation=function(t,e){if(this.isGroup())for(var n=this.entry.tree.getChildren(),r=0;r<n.length;r++){var i=n[r].properties.get(this.name);i&&i.set(t,u({},e,{propagation:!0,bubble:!1}))}},e.options={hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"},e}(s),h=function(){return(h=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},c=function(){function t(t,e){this.options={},this.entry=t,this._properties={},this._propertiesList=[],e&&e.forEach(this._setPropertyHandler.bind(this))}return t.prototype.add=function(t){this._setPropertyHandler(t)},t.prototype._setPropertyHandler=function(e){var n=t.handlers,r=e.handler;if(!r&&e.type)switch(e.type){case"boolean":r=n.CheckProperty;break;case"string":r=n.BaseProperty;break;default:r=n.BaseProperty}if(r){var i=h({},e||{});this._properties[e.name]=new r(e.name,this.entry,i),this._propertiesList.push(e.name)}},t.prototype.update=function(){this.list().forEach(function(t){t.update()})},t.prototype.value=function(t){var e=this.get(t);if(e)return e.value},t.prototype.set=function(t,e,n){var r=this.get(t);if(r)return r.set(e,n)},t.prototype.get=function(t){return this._properties[t]},t.prototype.list=function(){var t=this;return this._propertiesList.map(function(e){return t._properties[e]})},t.prototype.destroy=function(){for(var t in this._properties)if(this._properties.hasOwnProperty(t)){var e=this.get(t);e&&e.destroy&&e.destroy()}this._properties=null,this._propertiesList=[]},t.handlers={CheckProperty:p},t}(),l=0,f=function(){function t(t){this.emitter=new r.EventEmitter,this.options=Object.assign({},this.options,t),this.id=String(l++),this.tree=new o(this)}return t.prototype.initProperties=function(){this.properties=new c(this,this.options.properties)},t}(),y=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),d=function(){return(d=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},_=function(t){function e(n,r,i,o){var s=t.call(this,Object.assign({},e.options,i))||this;return s.map=n,s.item=r,o&&s.tree.setParent(o),s.initProperties(),s.initItem(r),s}return y(e,t),e.prototype.initItem=function(t){var n=this,r=t._layer;if("group"===t.item_type||"root"===t.item_type)t.children&&t.children.length&&t.children.forEach(function(t){var r=new e(n.map,t,n.options,n);n.tree.addChildren(r)});else if("layer"===t.item_type){var i=t.layer_adapter.toUpperCase();t.id=Number(this.id);var o=d({},t,{id:t.id});r=this.map.addLayer(i,o)}r&&(t._layer=r,"layer"===t.item_type&&t.layer_enabled&&this.properties.get("visibility").set(!0))},e.prototype.fit=function(){"layer"===this.item.item_type&&console.log(this.item)},e.options={properties:[{type:"boolean",name:"visibility",getProperty:function(){var t=this.entry;return"group"===t.item.item_type||("layer"===t.item.item_type?t.item.layer_enabled:"root"===t.item.item_type)},onSet:function(t){var e=this.entry;"layer"===e.item.item_type&&(t?e.map.showLayer(e.id):e.map.hideLayer(e.id),e.item.layer_enabled=t)}}]},e}(f),v=function(){return function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222}}(),b=function(){function t(){this.keyCodeAlias=new v,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];if(e)return this.keys[e]},t.prototype.addKeyboardEventsListener=function(){window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1)},t.prototype.removeKeyboardEventsListener=function(){window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1)},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}();n.d(e,"WebLayerEntry",function(){return _});var g=function(){return(g=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},m=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):new n(function(e){e(t.value)}).then(s,a)}u((r=r.apply(t,e||[])).next())})},w=function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},k=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise(function(r,i){(function(t,e,n,r){Promise.resolve(r).then(function(e){t({value:e,done:n})},e)})(r,i,(e=t[n](e)).done,e.value)})}}},P=function(){function t(t){this.displayProjection="EPSG:3857",this.lonlatProjection="EPSG:4326",this.emitter=new r.EventEmitter,this.keys=new b,this.settingsIsLoading=!1,this._baseLayers=[],this.map=t.mapAdapter,this._starterKits=t.starterKits||[],this._addEventsListeners()}return t.prototype.create=function(t){return m(this,void 0,void 0,function(){return w(this,function(e){switch(e.label){case 0:return this.options=function t(e,n,r){void 0===r&&(r=!1);var i=Array.isArray(n),o=i&&[]||{};return i?r?(e=e||[],o=o.concat(e),n.forEach(function(n,i){void 0===o[i]?o[i]=n:"object"==typeof n?o[i]=t(e[i],n,r):-1===e.indexOf(n)&&o.push(n)})):o=n:(e&&"object"==typeof e&&Object.keys(e).forEach(function(t){o[t]=e[t]}),Object.keys(n).forEach(function(i){"object"==typeof n[i]&&n[i]&&e[i]?o[i]=t(e[i],n[i],r):o[i]=n[i]})),o}(this.options||{},t),this.settings||!this._starterKits.length?[3,2]:[4,this.getSettings()];case 1:e.sent(),e.label=2;case 2:return[4,this._setupMap()];case 3:return e.sent(),[2,this]}})})},t.prototype.getSettings=function(){return m(this,void 0,void 0,function(){var t,e,n,r,i,o,s=this;return w(this,function(a){switch(a.label){case 0:return this.settings?[2,Promise.resolve(this.settings)]:this.settingsIsLoading?[2,new Promise(function(t){var e=function(n){t(n),s.emitter.removeListener("load-settings",e)};s.emitter.on("load-settings",e)})]:[3,1];case 1:this.settingsIsLoading=!0,t=void 0,a.label=2;case 2:a.trys.push([2,7,,8]),t={},e=0,n=this._starterKits.filter(function(t){return t.getSettings}),a.label=3;case 3:return e<n.length?[4,(r=n[e]).getSettings.call(r,this)]:[3,6];case 4:(i=a.sent())&&Object.assign(t,i),a.label=5;case 5:return e++,[3,3];case 6:return[3,8];case 7:throw o=a.sent(),this.settingsIsLoading=!1,new Error(o);case 8:if(t)return this.settings=t,this.settingsIsLoading=!1,this.emitter.emit("load-settings",t),[2,t];a.label=9;case 9:return[2]}})})},t.prototype.addBaseLayer=function(t,e,n){var r=this;return this.map.addLayer(e,g({},n,{id:t}),!0).then(function(t){return t&&r._baseLayers.push(t.name),t})},t.prototype.isBaseLayer=function(t){return-1!==this._baseLayers.indexOf(t)},t.prototype._setupMap=function(){return m(this,void 0,void 0,function(){var t,e,n,r,i,o;return w(this,function(s){switch(s.label){case 0:return this.settings&&(t=this.settings,e=t.extent_bottom,n=t.extent_left,r=t.extent_top,i=t.extent_right,e&&n&&r&&i&&(this._extent=[n,e,i,r],(o=this._extent)[3]>82&&(o[3]=82),o[1]<-82&&(o[1]=-82))),this.map.displayProjection=this.displayProjection,this.map.lonlatProjection=this.lonlatProjection,this.map.create(this.options),this._addTreeLayers(),[4,this._addLayerProviders()];case 1:return s.sent(),this._zoomToInitialExtent(),this.emitter.emit("build-map",this.map),[2,this]}})})},t.prototype._addTreeLayers=function(){return m(this,void 0,void 0,function(){var t,e;return w(this,function(n){switch(n.label){case 0:return[4,this.getSettings()];case 1:return(t=n.sent())&&(e=t.root_item)&&(this.layers=new _(this.map,e),this.emitter.emit("add-layers",this.layers)),[2]}})})},t.prototype._zoomToInitialExtent=function(){if(this._extent)this.map.fit(this._extent);else{var t=this.options,e=t.center,n=t.zoom;e&&this.map.setCenter(e),n&&this.map.setZoom(n)}},t.prototype._addLayerProviders=function(){return m(this,void 0,void 0,function(){var t,e,n,r,i,o,s,a,u,p,h,c,l,f,y;return w(this,function(d){switch(d.label){case 0:d.trys.push([0,26,,27]),d.label=1;case 1:d.trys.push([1,19,20,25]),i=k(this._starterKits.filter(function(t){return t.getLayerAdapters})),d.label=2;case 2:return[4,i.next()];case 3:return(o=d.sent()).done?[3,18]:[4,(s=o.value).getLayerAdapters.call(s)];case 4:if(!(a=d.sent()))return[3,17];d.label=5;case 5:d.trys.push([5,11,12,17]),u=k(a),d.label=6;case 6:return[4,u.next()];case 7:return(p=d.sent()).done?[3,10]:[4,(h=p.value).createAdapter(this.map)];case 8:(c=d.sent())&&(this.map.layerAdapters[h.name]=c),d.label=9;case 9:return[3,6];case 10:return[3,17];case 11:return l=d.sent(),n={error:l},[3,17];case 12:return d.trys.push([12,,15,16]),p&&!p.done&&(r=u.return)?[4,r.call(u)]:[3,14];case 13:d.sent(),d.label=14;case 14:return[3,16];case 15:if(n)throw n.error;return[7];case 16:return[7];case 17:return[3,2];case 18:return[3,25];case 19:return f=d.sent(),t={error:f},[3,25];case 20:return d.trys.push([20,,23,24]),o&&!o.done&&(e=i.return)?[4,e.call(i)]:[3,22];case 21:d.sent(),d.label=22;case 22:return[3,24];case 23:if(t)throw t.error;return[7];case 24:return[7];case 25:return[3,27];case 26:throw y=d.sent(),new Error(y);case 27:return[2]}})})},t.prototype._addEventsListeners=function(){var t=this;this.map.emitter.on("click",function(e){return t._onMapClick(e)})},t.prototype._onMapClick=function(t){var e=this;this.emitter.emit("click",t),this._starterKits.forEach(function(n){n.onMapClick&&n.onMapClick(t,e)})},t}();e.default=P}]).default}); | ||
//# sourceMappingURL=webmap.js.map |
{ | ||
"name": "@nextgis/webmap", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "", | ||
@@ -48,3 +48,3 @@ "main": "lib/webmap.js", | ||
"license": "GPL-3.0", | ||
"gitHead": "2ee188a3cdc997b6902d33224178b6a08538abc1" | ||
"gitHead": "fe9d702ecf91757d6f80c88543e2d797ffd3d05b" | ||
} |
@@ -0,0 +0,0 @@ # WebMap |
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
123801