@nextgis/webmap
Advanced tools
Comparing version 0.4.12 to 0.5.0
import { MapClickEvent } from './MapAdapter'; | ||
import { WebMap } from '../webmap'; | ||
import WebMap from '../webmap'; | ||
export interface TreeItem { | ||
@@ -4,0 +4,0 @@ item_type: 'root' | 'group' | 'layer'; |
@@ -5,4 +5,4 @@ /// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import { MapOptions } from '../webmap'; | ||
import { MapControls, MapControl } from './MapControl'; | ||
import { MapOptions } from './WebMapApp'; | ||
interface LatLng { | ||
@@ -9,0 +9,0 @@ lat: number; |
@@ -1,2 +0,2 @@ | ||
import { WebLayerEntry } from '../entities/WebLayerEntry'; | ||
import { WebLayerEntry } from '../WebLayerEntry'; | ||
import { MapAdapter } from './MapAdapter'; | ||
@@ -3,0 +3,0 @@ import { StarterKit } from './AppSettings'; |
@@ -1,9 +0,43 @@ | ||
import { WebMap } from './entities/WebMap'; | ||
/// <reference types="node" /> | ||
import { AppOptions, MapOptions } from './interfaces/WebMapApp'; | ||
import { MapAdapter, ControlPositions } from './interfaces/MapAdapter'; | ||
import { DialogAdapter, DialogAdapterOptions } from './interfaces/DialogAdapter'; | ||
import { MapControl, MapControls, AttributionControlOptions, ZoomControlOptions } from './interfaces/MapControl'; | ||
import { RuntimeParams } from './interfaces/RuntimeParams'; | ||
import { EventEmitter } from 'events'; | ||
import { WebLayerEntry } from './WebLayerEntry'; | ||
import { Keys } from './components/keys/Keys'; | ||
import { MapAdapter } from './interfaces/MapAdapter'; | ||
import { Type } from './utils/Type'; | ||
import { LayerAdapter, LayerAdapters } from './interfaces/LayerAdapter'; | ||
import { AppSettings } from './interfaces/AppSettings'; | ||
export { WebLayerEntry } from './WebLayerEntry'; | ||
export * from './interfaces/WebMapApp'; | ||
export * from './interfaces/MapAdapter'; | ||
export * from './interfaces/DialogAdapter'; | ||
export * from './interfaces/MapControl'; | ||
export * from './interfaces/LayerAdapter'; | ||
export * from './interfaces/AppSettings'; | ||
export { WebMap, AppOptions, MapOptions, MapAdapter, ControlPositions, DialogAdapter, DialogAdapterOptions, MapControl, MapControls, AttributionControlOptions, ZoomControlOptions, }; | ||
export declare function buildWebMap(appOpt: AppOptions, mapOpt: MapOptions): Promise<WebMap>; | ||
export default class WebMap<M = any> { | ||
options: MapOptions; | ||
displayProjection: string; | ||
lonlatProjection: string; | ||
settings: AppSettings; | ||
layers: WebLayerEntry; | ||
emitter: EventEmitter; | ||
keys: Keys; | ||
map: MapAdapter<M>; | ||
runtimeParams: RuntimeParams[]; | ||
private _starterKits; | ||
private settingsIsLoading; | ||
private _baseLayers; | ||
private _extent; | ||
constructor(appOptions: AppOptions); | ||
create(options: MapOptions): Promise<this>; | ||
getSettings(): Promise<AppSettings>; | ||
addBaseLayer(layerName: string, provider: keyof LayerAdapters | Type<LayerAdapter>, options?: any): Promise<LayerAdapter>; | ||
isBaseLayer(layerName: string): boolean; | ||
private _setupMap; | ||
private _addTreeLayers; | ||
private _zoomToInitialExtent; | ||
private _addLayerProviders; | ||
private _addEventsListeners; | ||
private _onMapClick; | ||
} |
1451
lib/webmap.js
@@ -1,1449 +0,2 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.WebMap = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
function __values(o) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; | ||
if (m) return m.call(o); | ||
return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
} | ||
function __asyncValues(o) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var m = o[Symbol.asyncIterator], i; | ||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); | ||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } | ||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } | ||
} | ||
function deepmerge(target, src, mergeArray) { | ||
if (mergeArray === void 0) { mergeArray = false; } | ||
var array = Array.isArray(src); | ||
var dst = array && [] || {}; | ||
if (array) { | ||
if (mergeArray) { | ||
target = target || []; | ||
dst = dst.concat(target); | ||
src.forEach(function (e, i) { | ||
if (typeof dst[i] === 'undefined') { | ||
dst[i] = e; | ||
} | ||
else if (typeof e === 'object') { | ||
dst[i] = deepmerge(target[i], e, mergeArray); | ||
} | ||
else { | ||
if (target.indexOf(e) === -1) { | ||
dst.push(e); | ||
} | ||
} | ||
}); | ||
} | ||
else { | ||
dst = src; | ||
} | ||
} | ||
else { | ||
if (target && typeof target === 'object') { | ||
Object.keys(target).forEach(function (key) { | ||
dst[key] = target[key]; | ||
}); | ||
} | ||
Object.keys(src).forEach(function (key) { | ||
if (typeof src[key] !== 'object' || !src[key]) { | ||
dst[key] = src[key]; | ||
} | ||
else { | ||
if (!target[key]) { | ||
dst[key] = src[key]; | ||
} | ||
else { | ||
dst[key] = deepmerge(target[key], src[key], mergeArray); | ||
} | ||
} | ||
}); | ||
} | ||
return dst; | ||
} | ||
var domain; | ||
// This constructor is used to store event handlers. Instantiating this is | ||
// faster than explicitly calling `Object.create(null)` to get a "clean" empty | ||
// object (tested with v8 v4.9). | ||
function EventHandlers() {} | ||
EventHandlers.prototype = Object.create(null); | ||
function EventEmitter() { | ||
EventEmitter.init.call(this); | ||
} | ||
// nodejs oddity | ||
// require('events') === require('events').EventEmitter | ||
EventEmitter.EventEmitter = EventEmitter; | ||
EventEmitter.usingDomains = false; | ||
EventEmitter.prototype.domain = undefined; | ||
EventEmitter.prototype._events = undefined; | ||
EventEmitter.prototype._maxListeners = undefined; | ||
// By default EventEmitters will print a warning if more than 10 listeners are | ||
// added to it. This is a useful default which helps finding memory leaks. | ||
EventEmitter.defaultMaxListeners = 10; | ||
EventEmitter.init = function() { | ||
this.domain = null; | ||
if (EventEmitter.usingDomains) { | ||
// if there is an active domain, then attach to it. | ||
if (domain.active && !(this instanceof domain.Domain)) ; | ||
} | ||
if (!this._events || this._events === Object.getPrototypeOf(this)._events) { | ||
this._events = new EventHandlers(); | ||
this._eventsCount = 0; | ||
} | ||
this._maxListeners = this._maxListeners || undefined; | ||
}; | ||
// Obviously not all Emitters should be limited to 10. This function allows | ||
// that to be increased. Set to zero for unlimited. | ||
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { | ||
if (typeof n !== 'number' || n < 0 || isNaN(n)) | ||
throw new TypeError('"n" argument must be a positive number'); | ||
this._maxListeners = n; | ||
return this; | ||
}; | ||
function $getMaxListeners(that) { | ||
if (that._maxListeners === undefined) | ||
return EventEmitter.defaultMaxListeners; | ||
return that._maxListeners; | ||
} | ||
EventEmitter.prototype.getMaxListeners = function getMaxListeners() { | ||
return $getMaxListeners(this); | ||
}; | ||
// These standalone emit* functions are used to optimize calling of event | ||
// handlers for fast cases because emit() itself often has a variable number of | ||
// arguments and can be deoptimized because of that. These functions always have | ||
// the same number of arguments and thus do not get deoptimized, so the code | ||
// inside them can execute faster. | ||
function emitNone(handler, isFn, self) { | ||
if (isFn) | ||
handler.call(self); | ||
else { | ||
var len = handler.length; | ||
var listeners = arrayClone(handler, len); | ||
for (var i = 0; i < len; ++i) | ||
listeners[i].call(self); | ||
} | ||
} | ||
function emitOne(handler, isFn, self, arg1) { | ||
if (isFn) | ||
handler.call(self, arg1); | ||
else { | ||
var len = handler.length; | ||
var listeners = arrayClone(handler, len); | ||
for (var i = 0; i < len; ++i) | ||
listeners[i].call(self, arg1); | ||
} | ||
} | ||
function emitTwo(handler, isFn, self, arg1, arg2) { | ||
if (isFn) | ||
handler.call(self, arg1, arg2); | ||
else { | ||
var len = handler.length; | ||
var listeners = arrayClone(handler, len); | ||
for (var i = 0; i < len; ++i) | ||
listeners[i].call(self, arg1, arg2); | ||
} | ||
} | ||
function emitThree(handler, isFn, self, arg1, arg2, arg3) { | ||
if (isFn) | ||
handler.call(self, arg1, arg2, arg3); | ||
else { | ||
var len = handler.length; | ||
var listeners = arrayClone(handler, len); | ||
for (var i = 0; i < len; ++i) | ||
listeners[i].call(self, arg1, arg2, arg3); | ||
} | ||
} | ||
function emitMany(handler, isFn, self, args) { | ||
if (isFn) | ||
handler.apply(self, args); | ||
else { | ||
var len = handler.length; | ||
var listeners = arrayClone(handler, len); | ||
for (var i = 0; i < len; ++i) | ||
listeners[i].apply(self, args); | ||
} | ||
} | ||
EventEmitter.prototype.emit = function emit(type) { | ||
var er, handler, len, args, i, events, domain; | ||
var doError = (type === 'error'); | ||
events = this._events; | ||
if (events) | ||
doError = (doError && events.error == null); | ||
else if (!doError) | ||
return false; | ||
domain = this.domain; | ||
// If there is no 'error' event listener then throw. | ||
if (doError) { | ||
er = arguments[1]; | ||
if (domain) { | ||
if (!er) | ||
er = new Error('Uncaught, unspecified "error" event'); | ||
er.domainEmitter = this; | ||
er.domain = domain; | ||
er.domainThrown = false; | ||
domain.emit('error', er); | ||
} else if (er instanceof Error) { | ||
throw er; // Unhandled 'error' event | ||
} else { | ||
// At least give some kind of context to the user | ||
var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); | ||
err.context = er; | ||
throw err; | ||
} | ||
return false; | ||
} | ||
handler = events[type]; | ||
if (!handler) | ||
return false; | ||
var isFn = typeof handler === 'function'; | ||
len = arguments.length; | ||
switch (len) { | ||
// fast cases | ||
case 1: | ||
emitNone(handler, isFn, this); | ||
break; | ||
case 2: | ||
emitOne(handler, isFn, this, arguments[1]); | ||
break; | ||
case 3: | ||
emitTwo(handler, isFn, this, arguments[1], arguments[2]); | ||
break; | ||
case 4: | ||
emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]); | ||
break; | ||
// slower | ||
default: | ||
args = new Array(len - 1); | ||
for (i = 1; i < len; i++) | ||
args[i - 1] = arguments[i]; | ||
emitMany(handler, isFn, this, args); | ||
} | ||
return true; | ||
}; | ||
function _addListener(target, type, listener, prepend) { | ||
var m; | ||
var events; | ||
var existing; | ||
if (typeof listener !== 'function') | ||
throw new TypeError('"listener" argument must be a function'); | ||
events = target._events; | ||
if (!events) { | ||
events = target._events = new EventHandlers(); | ||
target._eventsCount = 0; | ||
} else { | ||
// To avoid recursion in the case that type === "newListener"! Before | ||
// adding it to the listeners, first emit "newListener". | ||
if (events.newListener) { | ||
target.emit('newListener', type, | ||
listener.listener ? listener.listener : listener); | ||
// Re-assign `events` because a newListener handler could have caused the | ||
// this._events to be assigned to a new object | ||
events = target._events; | ||
} | ||
existing = events[type]; | ||
} | ||
if (!existing) { | ||
// Optimize the case of one listener. Don't need the extra array object. | ||
existing = events[type] = listener; | ||
++target._eventsCount; | ||
} else { | ||
if (typeof existing === 'function') { | ||
// Adding the second element, need to change to array. | ||
existing = events[type] = prepend ? [listener, existing] : | ||
[existing, listener]; | ||
} else { | ||
// If we've already got an array, just append. | ||
if (prepend) { | ||
existing.unshift(listener); | ||
} else { | ||
existing.push(listener); | ||
} | ||
} | ||
// Check for listener leak | ||
if (!existing.warned) { | ||
m = $getMaxListeners(target); | ||
if (m && m > 0 && existing.length > m) { | ||
existing.warned = true; | ||
var w = new Error('Possible EventEmitter memory leak detected. ' + | ||
existing.length + ' ' + type + ' listeners added. ' + | ||
'Use emitter.setMaxListeners() to increase limit'); | ||
w.name = 'MaxListenersExceededWarning'; | ||
w.emitter = target; | ||
w.type = type; | ||
w.count = existing.length; | ||
emitWarning(w); | ||
} | ||
} | ||
} | ||
return target; | ||
} | ||
function emitWarning(e) { | ||
typeof console.warn === 'function' ? console.warn(e) : console.log(e); | ||
} | ||
EventEmitter.prototype.addListener = function addListener(type, listener) { | ||
return _addListener(this, type, listener, false); | ||
}; | ||
EventEmitter.prototype.on = EventEmitter.prototype.addListener; | ||
EventEmitter.prototype.prependListener = | ||
function prependListener(type, listener) { | ||
return _addListener(this, type, listener, true); | ||
}; | ||
function _onceWrap(target, type, listener) { | ||
var fired = false; | ||
function g() { | ||
target.removeListener(type, g); | ||
if (!fired) { | ||
fired = true; | ||
listener.apply(target, arguments); | ||
} | ||
} | ||
g.listener = listener; | ||
return g; | ||
} | ||
EventEmitter.prototype.once = function once(type, listener) { | ||
if (typeof listener !== 'function') | ||
throw new TypeError('"listener" argument must be a function'); | ||
this.on(type, _onceWrap(this, type, listener)); | ||
return this; | ||
}; | ||
EventEmitter.prototype.prependOnceListener = | ||
function prependOnceListener(type, listener) { | ||
if (typeof listener !== 'function') | ||
throw new TypeError('"listener" argument must be a function'); | ||
this.prependListener(type, _onceWrap(this, type, listener)); | ||
return this; | ||
}; | ||
// emits a 'removeListener' event iff the listener was removed | ||
EventEmitter.prototype.removeListener = | ||
function removeListener(type, listener) { | ||
var list, events, position, i, originalListener; | ||
if (typeof listener !== 'function') | ||
throw new TypeError('"listener" argument must be a function'); | ||
events = this._events; | ||
if (!events) | ||
return this; | ||
list = events[type]; | ||
if (!list) | ||
return this; | ||
if (list === listener || (list.listener && list.listener === listener)) { | ||
if (--this._eventsCount === 0) | ||
this._events = new EventHandlers(); | ||
else { | ||
delete events[type]; | ||
if (events.removeListener) | ||
this.emit('removeListener', type, list.listener || listener); | ||
} | ||
} else if (typeof list !== 'function') { | ||
position = -1; | ||
for (i = list.length; i-- > 0;) { | ||
if (list[i] === listener || | ||
(list[i].listener && list[i].listener === listener)) { | ||
originalListener = list[i].listener; | ||
position = i; | ||
break; | ||
} | ||
} | ||
if (position < 0) | ||
return this; | ||
if (list.length === 1) { | ||
list[0] = undefined; | ||
if (--this._eventsCount === 0) { | ||
this._events = new EventHandlers(); | ||
return this; | ||
} else { | ||
delete events[type]; | ||
} | ||
} else { | ||
spliceOne(list, position); | ||
} | ||
if (events.removeListener) | ||
this.emit('removeListener', type, originalListener || listener); | ||
} | ||
return this; | ||
}; | ||
EventEmitter.prototype.removeAllListeners = | ||
function removeAllListeners(type) { | ||
var listeners, events; | ||
events = this._events; | ||
if (!events) | ||
return this; | ||
// not listening for removeListener, no need to emit | ||
if (!events.removeListener) { | ||
if (arguments.length === 0) { | ||
this._events = new EventHandlers(); | ||
this._eventsCount = 0; | ||
} else if (events[type]) { | ||
if (--this._eventsCount === 0) | ||
this._events = new EventHandlers(); | ||
else | ||
delete events[type]; | ||
} | ||
return this; | ||
} | ||
// emit removeListener for all listeners on all events | ||
if (arguments.length === 0) { | ||
var keys = Object.keys(events); | ||
for (var i = 0, key; i < keys.length; ++i) { | ||
key = keys[i]; | ||
if (key === 'removeListener') continue; | ||
this.removeAllListeners(key); | ||
} | ||
this.removeAllListeners('removeListener'); | ||
this._events = new EventHandlers(); | ||
this._eventsCount = 0; | ||
return this; | ||
} | ||
listeners = events[type]; | ||
if (typeof listeners === 'function') { | ||
this.removeListener(type, listeners); | ||
} else if (listeners) { | ||
// LIFO order | ||
do { | ||
this.removeListener(type, listeners[listeners.length - 1]); | ||
} while (listeners[0]); | ||
} | ||
return this; | ||
}; | ||
EventEmitter.prototype.listeners = function listeners(type) { | ||
var evlistener; | ||
var ret; | ||
var events = this._events; | ||
if (!events) | ||
ret = []; | ||
else { | ||
evlistener = events[type]; | ||
if (!evlistener) | ||
ret = []; | ||
else if (typeof evlistener === 'function') | ||
ret = [evlistener.listener || evlistener]; | ||
else | ||
ret = unwrapListeners(evlistener); | ||
} | ||
return ret; | ||
}; | ||
EventEmitter.listenerCount = function(emitter, type) { | ||
if (typeof emitter.listenerCount === 'function') { | ||
return emitter.listenerCount(type); | ||
} else { | ||
return listenerCount.call(emitter, type); | ||
} | ||
}; | ||
EventEmitter.prototype.listenerCount = listenerCount; | ||
function listenerCount(type) { | ||
var events = this._events; | ||
if (events) { | ||
var evlistener = events[type]; | ||
if (typeof evlistener === 'function') { | ||
return 1; | ||
} else if (evlistener) { | ||
return evlistener.length; | ||
} | ||
} | ||
return 0; | ||
} | ||
EventEmitter.prototype.eventNames = function eventNames() { | ||
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : []; | ||
}; | ||
// About 1.5x faster than the two-arg version of Array#splice(). | ||
function spliceOne(list, index) { | ||
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) | ||
list[i] = list[k]; | ||
list.pop(); | ||
} | ||
function arrayClone(arr, i) { | ||
var copy = new Array(i); | ||
while (i--) | ||
copy[i] = arr[i]; | ||
return copy; | ||
} | ||
function unwrapListeners(arr) { | ||
var ret = new Array(arr.length); | ||
for (var i = 0; i < ret.length; ++i) { | ||
ret[i] = arr[i].listener || arr[i]; | ||
} | ||
return ret; | ||
} | ||
function filterIn(entry, filterFunc, relationFunc, _filtered) { | ||
if (filterFunc === void 0) { filterFunc = function (x) { return x; }; } | ||
if (_filtered === void 0) { _filtered = []; } | ||
var child; | ||
if (Array.isArray(entry)) { | ||
child = entry; | ||
} | ||
else { | ||
var filter = filterFunc(entry); | ||
if (filter) { | ||
_filtered.push(entry); | ||
} | ||
var relChild = relationFunc(entry); | ||
if (relChild) { | ||
child = [].concat(relChild); | ||
} | ||
} | ||
if (child) { | ||
for (var fry = 0; fry < child.length; fry++) { | ||
if (child[fry]) { | ||
filterIn(child[fry], filterFunc, relationFunc, _filtered); | ||
} | ||
} | ||
} | ||
return _filtered; | ||
} | ||
var TreeHelper = (function () { | ||
function TreeHelper(entry) { | ||
this._children = []; | ||
this.entry = entry; | ||
} | ||
TreeHelper.prototype.setParent = function (parent) { | ||
this._parent = parent; | ||
}; | ||
TreeHelper.prototype.addChildren = function (children) { | ||
this._children.push(children); | ||
}; | ||
TreeHelper.prototype.getParent = function () { | ||
return this._parent; | ||
}; | ||
TreeHelper.prototype.getParents = function (filterFunc) { | ||
if (this.getParent()) { | ||
var generator = filterIn(this._parent, filterFunc, function (x) { return x.tree.getParent(); }); | ||
return generator; | ||
} | ||
return []; | ||
}; | ||
TreeHelper.prototype.getDescendants = function (filterFunc) { | ||
return filterIn(this._children, filterFunc, function (x) { | ||
return x.tree.getChildren(); | ||
}); | ||
}; | ||
TreeHelper.prototype.getChildren = function () { | ||
return this._children; | ||
}; | ||
return TreeHelper; | ||
}()); | ||
var BaseProperty = (function () { | ||
function BaseProperty(name, entry, options) { | ||
this.emitter = new EventEmitter(); | ||
this.entry = entry; | ||
this.options = Object.assign({}, options); | ||
this.name = name; | ||
this._value = this.getProperty(); | ||
} | ||
BaseProperty.prototype.getProperty = function () { | ||
if (typeof this.options.getProperty === 'function') { | ||
return this.options.getProperty.call(this); | ||
} | ||
return this.options.value; | ||
}; | ||
BaseProperty.prototype.getParents = function () { | ||
return this.entry.tree.getParents() || []; | ||
}; | ||
BaseProperty.prototype.getParent = function () { | ||
return this.entry.tree.getParent(); | ||
}; | ||
BaseProperty.prototype.isGroup = function () { | ||
var children = this.entry.tree.getDescendants(); | ||
return children.length; | ||
}; | ||
BaseProperty.prototype.isBlocked = function () { | ||
var _this = this; | ||
if (this._blocked === undefined) { | ||
var parents = this.entry.tree.getParents(); | ||
if (parents) { | ||
var isBlocked = parents.find(function (x) { | ||
var parentProp = x.properties.get(_this.name); | ||
if (parentProp) { | ||
return !parentProp.value(); | ||
} | ||
}); | ||
this._blocked = !!isBlocked; | ||
} | ||
else { | ||
this._blocked = false; | ||
} | ||
} | ||
return this._blocked; | ||
}; | ||
BaseProperty.prototype.set = function (value, options) { | ||
this._value = this._prepareValue(value); | ||
this.update(this._value, options); | ||
this._fireChangeEvent(this._value, options); | ||
}; | ||
BaseProperty.prototype.value = function () { | ||
return this.getValue(); | ||
}; | ||
BaseProperty.prototype.update = function (value, options) { | ||
this._callOnSet(value, options); | ||
}; | ||
BaseProperty.prototype.getContainer = function () { | ||
return this._container; | ||
}; | ||
BaseProperty.prototype.destroy = function () { | ||
if (this._container) { | ||
this._container.parentNode.removeChild(this._container); | ||
} | ||
if (this._removeEventsListener) { | ||
this._removeEventsListener(); | ||
} | ||
}; | ||
BaseProperty.prototype.getValue = function () { | ||
return this._value !== undefined ? this._value : this.getProperty(); | ||
}; | ||
BaseProperty.prototype._prepareValue = function (value) { | ||
return value; | ||
}; | ||
BaseProperty.prototype._callOnSet = function (value, options) { | ||
if (this.options.onSet) { | ||
this.options.onSet.call(this, value, options); | ||
} | ||
}; | ||
BaseProperty.prototype._fireChangeEvent = function (value, options) { | ||
var _this = this; | ||
value = value !== undefined ? value : this.getValue(); | ||
this.emitter.emit('change', { value: value, options: options }); | ||
var parents = this.entry.tree.getParents(); | ||
parents.forEach(function (x) { | ||
var prop = x.properties.get(_this.name); | ||
if (prop) { | ||
prop.emitter.emit('change-tree', { value: value, options: options, entry: _this.entry }); | ||
} | ||
}); | ||
}; | ||
return BaseProperty; | ||
}()); | ||
var CheckProperty = (function (_super) { | ||
__extends(CheckProperty, _super); | ||
function CheckProperty(name, entry, options) { | ||
var _this = _super.call(this, name, entry, Object.assign({}, CheckProperty.options, options)) || this; | ||
_this.set(_this.value()); | ||
return _this; | ||
} | ||
CheckProperty.prototype.update = function (value, options) { | ||
if (value) { | ||
var bubble = (options && options.bubble) || this.options.bubble; | ||
if (bubble) { | ||
this.unBlock(options); | ||
var parent_1 = this.getParent(); | ||
var property = parent_1 && parent_1.properties.get(this.name); | ||
if (property) { | ||
property.set(value, Object.assign({}, options, { bubble: true, propagation: false })); | ||
} | ||
} | ||
if (!this.isBlocked()) { | ||
this._turnOn(options); | ||
} | ||
} | ||
else { | ||
this._turnOff(options); | ||
} | ||
var propagation = (options && options.propagation) || this.options.propagation; | ||
if (propagation) { | ||
this._propagation(value, options); | ||
} | ||
}; | ||
CheckProperty.prototype.getHierarchyValue = function () { | ||
var _this = this; | ||
return this.value() && this.getParents().every(function (x) { | ||
var property = x.properties[_this.name]; | ||
return property && property.get(); | ||
}); | ||
}; | ||
CheckProperty.prototype._prepareValue = function (value) { | ||
return !!value; | ||
}; | ||
CheckProperty.prototype._turnOff = function (options) { | ||
if (this.options.turnOff) { | ||
this.options.turnOff.call(this, options); | ||
} | ||
this._callOnSet(false, options); | ||
if (this.options.hierarchy && this.isGroup()) { | ||
this.blockChilds(options); | ||
} | ||
}; | ||
CheckProperty.prototype._turnOn = function (options) { | ||
if (this.options.turnOn) { | ||
this.options.turnOn.call(this, options); | ||
} | ||
this._callOnSet(true, options); | ||
if (this.options.hierarchy && this.isGroup()) { | ||
this.unblockChilds(options); | ||
} | ||
}; | ||
CheckProperty.prototype.block = function (options) { | ||
this._blocked = true; | ||
this._block(options); | ||
}; | ||
CheckProperty.prototype._block = function (options) { | ||
this._turnOff(options); | ||
}; | ||
CheckProperty.prototype.unBlock = function (options) { | ||
this._blocked = false; | ||
if (this.getValue()) { | ||
this._unBlock(options); | ||
} | ||
}; | ||
CheckProperty.prototype._unBlock = function (options) { | ||
this._turnOn(options); | ||
}; | ||
CheckProperty.prototype.blockChilds = function (options) { | ||
this.entry.tree.getDescendants().forEach(this._blockChild.bind(this, options)); | ||
}; | ||
CheckProperty.prototype.unblockChilds = function (options) { | ||
this.entry.tree.getChildren().forEach(this._unBlockChild.bind(this, options)); | ||
}; | ||
CheckProperty.prototype._blockChild = function (options, entry) { | ||
var prop = entry.properties.get(this.name); | ||
if (prop.block) { | ||
prop.block(options); | ||
} | ||
}; | ||
CheckProperty.prototype._unBlockChild = function (options, entry) { | ||
var prop = entry.properties.get(this.name); | ||
if (prop.unBlock) { | ||
prop.unBlock(options); | ||
} | ||
}; | ||
CheckProperty.prototype._propagation = function (value, options) { | ||
if (this.isGroup()) { | ||
var childs = this.entry.tree.getChildren(); | ||
for (var fry = 0; fry < childs.length; fry++) { | ||
var child = childs[fry]; | ||
var property = child.properties.get(this.name); | ||
if (property) { | ||
property.set(value, __assign({}, options, { | ||
propagation: true, | ||
bubble: false, | ||
})); | ||
} | ||
} | ||
} | ||
}; | ||
CheckProperty.options = { | ||
hierarchy: true, | ||
bubble: false, | ||
propagation: false, | ||
label: 'Toggle', | ||
}; | ||
return CheckProperty; | ||
}(BaseProperty)); | ||
var EntryProperties = (function () { | ||
function EntryProperties(entry, propertiesList) { | ||
this.options = {}; | ||
this.entry = entry; | ||
this._properties = {}; | ||
this._propertiesList = []; | ||
if (propertiesList) { | ||
propertiesList.forEach(this._setPropertyHandler.bind(this)); | ||
} | ||
} | ||
EntryProperties.prototype.add = function (propOpt) { | ||
this._setPropertyHandler(propOpt); | ||
}; | ||
EntryProperties.prototype._setPropertyHandler = function (propOpt) { | ||
var handlers = EntryProperties.handlers; | ||
var handler = propOpt.handler; | ||
if (!handler && propOpt.type) { | ||
switch (propOpt.type) { | ||
case 'boolean': | ||
handler = handlers.CheckProperty; | ||
break; | ||
case 'string': | ||
handler = handlers.BaseProperty; | ||
break; | ||
default: | ||
handler = handlers.BaseProperty; | ||
} | ||
} | ||
if (handler) { | ||
var options = __assign({}, propOpt || {}); | ||
this._properties[propOpt.name] = new handler(propOpt.name, this.entry, options); | ||
this._propertiesList.push(propOpt.name); | ||
} | ||
}; | ||
EntryProperties.prototype.update = function () { | ||
this.list().forEach(function (x) { | ||
x.update(); | ||
}); | ||
}; | ||
EntryProperties.prototype.value = function (name) { | ||
var prop = this.get(name); | ||
if (prop) { | ||
return prop.value; | ||
} | ||
}; | ||
EntryProperties.prototype.set = function (name, value, options) { | ||
var prop = this.get(name); | ||
if (prop) { | ||
return prop.set(value, options); | ||
} | ||
}; | ||
EntryProperties.prototype.get = function (name) { | ||
return this._properties[name]; | ||
}; | ||
EntryProperties.prototype.list = function () { | ||
var _this = this; | ||
return this._propertiesList.map(function (x) { return _this._properties[x]; }); | ||
}; | ||
EntryProperties.prototype.destroy = function () { | ||
for (var p in this._properties) { | ||
if (this._properties.hasOwnProperty(p)) { | ||
var prop = this.get(p); | ||
if (prop && prop.destroy) { | ||
prop.destroy(); | ||
} | ||
} | ||
} | ||
this._properties = null; | ||
this._propertiesList = []; | ||
}; | ||
EntryProperties.handlers = { | ||
CheckProperty: CheckProperty, | ||
}; | ||
return EntryProperties; | ||
}()); | ||
var ID = 0; | ||
var Entry = (function () { | ||
function Entry(options) { | ||
this.emitter = new EventEmitter(); | ||
this.options = Object.assign({}, this.options, options); | ||
this.id = String(ID++); | ||
this.tree = new TreeHelper(this); | ||
} | ||
Entry.prototype.initProperties = function () { | ||
this.properties = new EntryProperties(this, this.options.properties); | ||
}; | ||
return Entry; | ||
}()); | ||
var WebLayerEntry = (function (_super) { | ||
__extends(WebLayerEntry, _super); | ||
function WebLayerEntry(map, item, options, parent) { | ||
var _this = _super.call(this, Object.assign({}, WebLayerEntry.options, options)) || this; | ||
_this.map = map; | ||
_this.item = item; | ||
if (parent) { | ||
_this.tree.setParent(parent); | ||
} | ||
_this.initProperties(); | ||
_this.initItem(item); | ||
return _this; | ||
} | ||
WebLayerEntry.prototype.initItem = function (item) { | ||
var _this = this; | ||
var newLayer = item._layer; | ||
if (item.item_type === 'group' || item.item_type === 'root') { | ||
if (item.children && item.children.length) { | ||
item.children.forEach(function (x) { | ||
var children = new WebLayerEntry(_this.map, x, _this.options, _this); | ||
_this.tree.addChildren(children); | ||
}); | ||
} | ||
} | ||
else if (item.item_type === 'layer') { | ||
var adapter = item.layer_adapter.toUpperCase(); | ||
newLayer = this.map.addLayer(adapter, Object.assign({ | ||
id: this.id, | ||
}, item)); | ||
} | ||
if (newLayer) { | ||
item._layer = newLayer; | ||
if (item.item_type === 'layer' && item.layer_enabled) { | ||
this.properties.get('visibility').set(true); | ||
} | ||
} | ||
}; | ||
WebLayerEntry.prototype.fit = function () { | ||
if (this.item.item_type === 'layer') { | ||
console.log(this.item); | ||
} | ||
}; | ||
WebLayerEntry.options = { | ||
properties: [ | ||
{ | ||
type: 'boolean', | ||
name: 'visibility', | ||
getProperty: function () { | ||
var entry = this.entry; | ||
if (entry.item.item_type === 'group') { | ||
return true; | ||
} | ||
else if (entry.item.item_type === 'layer') { | ||
return entry.item.layer_enabled; | ||
} | ||
else if (entry.item.item_type === 'root') { | ||
return true; | ||
} | ||
return false; | ||
}, | ||
onSet: function (value) { | ||
var entry = this.entry; | ||
if (entry.item.item_type === 'layer') { | ||
if (value) { | ||
entry.map.showLayer(entry.id); | ||
} | ||
else { | ||
entry.map.hideLayer(entry.id); | ||
} | ||
entry.item.layer_enabled = value; | ||
} | ||
}, | ||
}, | ||
], | ||
}; | ||
return WebLayerEntry; | ||
}(Entry)); | ||
var KeyCodes = (function () { | ||
function KeyCodes() { | ||
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; | ||
} | ||
return KeyCodes; | ||
}()); | ||
var Keys = (function () { | ||
function Keys() { | ||
this.keyCodeAlias = new KeyCodes(); | ||
this.keys = {}; | ||
this._windowOnFocus = this.windowOnFocus.bind(this); | ||
this._keysPressed = this.keysPressed.bind(this); | ||
this._keysReleased = this.keysReleased.bind(this); | ||
this.addKeyboardEventsListener(); | ||
} | ||
Keys.prototype.pressed = function (keyName) { | ||
var code = this.keyCodeAlias[keyName]; | ||
if (code) { | ||
return this.keys[code]; | ||
} | ||
}; | ||
Keys.prototype.addKeyboardEventsListener = function () { | ||
window.addEventListener('focus', this._windowOnFocus, false); | ||
window.addEventListener('keydown', this._keysPressed, false); | ||
window.addEventListener('keyup', this._keysReleased, false); | ||
}; | ||
Keys.prototype.removeKeyboardEventsListener = function () { | ||
window.removeEventListener('focus', this._windowOnFocus, false); | ||
window.removeEventListener('keydown', this._keysPressed, false); | ||
window.removeEventListener('keyup', this._keysReleased, false); | ||
}; | ||
Keys.prototype.keysPressed = function (e) { | ||
e.stopPropagation(); | ||
if (!this.keys[e.keyCode]) { | ||
this.keys[e.keyCode] = true; | ||
} | ||
}; | ||
Keys.prototype.keysReleased = function (e) { | ||
e.stopPropagation(); | ||
this.keys[e.keyCode] = false; | ||
}; | ||
Keys.prototype.windowOnFocus = function () { | ||
this.keys = {}; | ||
}; | ||
return Keys; | ||
}()); | ||
var WebMap = (function () { | ||
function WebMap(appOptions) { | ||
this.displayProjection = 'EPSG:3857'; | ||
this.lonlatProjection = 'EPSG:4326'; | ||
this.emitter = new EventEmitter(); | ||
this.keys = new Keys(); | ||
this.settingsIsLoading = false; | ||
this._baseLayers = []; | ||
this.map = appOptions.mapAdapter; | ||
this._starterKits = appOptions.starterKits || []; | ||
this._addEventsListeners(); | ||
} | ||
WebMap.prototype.create = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
this.options = deepmerge(this.options || {}, options); | ||
if (!(!this.settings && this._starterKits.length)) return [3, 2]; | ||
return [4, this.getSettings()]; | ||
case 1: | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: return [4, this._setupMap()]; | ||
case 3: | ||
_a.sent(); | ||
return [2, this]; | ||
} | ||
}); | ||
}); | ||
}; | ||
WebMap.prototype.getSettings = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var settings, _i, _a, kit, setting, er_1; | ||
var _this = this; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (this.settings) { | ||
return [2, Promise.resolve(this.settings)]; | ||
} | ||
if (!this.settingsIsLoading) return [3, 1]; | ||
return [2, new Promise(function (resolve) { | ||
var onLoad = function (x) { | ||
resolve(x); | ||
_this.emitter.removeListener('load-settings', onLoad); | ||
}; | ||
_this.emitter.on('load-settings', onLoad); | ||
})]; | ||
case 1: | ||
this.settingsIsLoading = true; | ||
settings = void 0; | ||
_b.label = 2; | ||
case 2: | ||
_b.trys.push([2, 7, , 8]); | ||
settings = {}; | ||
_i = 0, _a = this._starterKits.filter(function (x) { return x.getSettings; }); | ||
_b.label = 3; | ||
case 3: | ||
if (!(_i < _a.length)) return [3, 6]; | ||
kit = _a[_i]; | ||
return [4, kit.getSettings.call(kit)]; | ||
case 4: | ||
setting = _b.sent(); | ||
if (setting) { | ||
Object.assign(settings, setting); | ||
} | ||
_b.label = 5; | ||
case 5: | ||
_i++; | ||
return [3, 3]; | ||
case 6: return [3, 8]; | ||
case 7: | ||
er_1 = _b.sent(); | ||
this.settingsIsLoading = false; | ||
throw new Error(er_1); | ||
case 8: | ||
if (settings) { | ||
this.settings = settings; | ||
this.settingsIsLoading = false; | ||
this.emitter.emit('load-settings', settings); | ||
return [2, settings]; | ||
} | ||
_b.label = 9; | ||
case 9: return [2]; | ||
} | ||
}); | ||
}); | ||
}; | ||
WebMap.prototype.addBaseLayer = function (layerName, provider, options) { | ||
var _this = this; | ||
return this.map.addLayer(provider, __assign({}, options, { id: layerName }), true).then(function (layer) { | ||
if (layer) { | ||
_this._baseLayers.push(layer.name); | ||
} | ||
return layer; | ||
}); | ||
}; | ||
WebMap.prototype.isBaseLayer = function (layerName) { | ||
return this._baseLayers.indexOf(layerName) !== -1; | ||
}; | ||
WebMap.prototype._setupMap = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, extent_bottom, extent_left, extent_top, extent_right, extent; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (this.settings) { | ||
_a = this.settings, extent_bottom = _a.extent_bottom, extent_left = _a.extent_left, extent_top = _a.extent_top, extent_right = _a.extent_right; | ||
if (extent_bottom && extent_left && extent_top && extent_right) { | ||
this._extent = [extent_left, extent_bottom, extent_right, extent_top]; | ||
extent = this._extent; | ||
if (extent[3] > 82) { | ||
extent[3] = 82; | ||
} | ||
if (extent[1] < -82) { | ||
extent[1] = -82; | ||
} | ||
} | ||
} | ||
this.map.displayProjection = this.displayProjection; | ||
this.map.lonlatProjection = this.lonlatProjection; | ||
this.map.create(this.options); | ||
this._addTreeLayers(); | ||
return [4, this._addLayerProviders()]; | ||
case 1: | ||
_b.sent(); | ||
this._zoomToInitialExtent(); | ||
this.emitter.emit('build-map', this.map); | ||
return [2, this]; | ||
} | ||
}); | ||
}); | ||
}; | ||
WebMap.prototype._addTreeLayers = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var settings, rootLayer; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, this.getSettings()]; | ||
case 1: | ||
settings = _a.sent(); | ||
if (settings) { | ||
rootLayer = settings.root_item; | ||
if (rootLayer) { | ||
this.layers = new WebLayerEntry(this.map, rootLayer); | ||
this.emitter.emit('add-layers', this.layers); | ||
} | ||
} | ||
return [2]; | ||
} | ||
}); | ||
}); | ||
}; | ||
WebMap.prototype._zoomToInitialExtent = function () { | ||
if (this._extent) { | ||
this.map.fit(this._extent); | ||
} | ||
else { | ||
var _a = this.options, center = _a.center, zoom = _a.zoom; | ||
if (center) { | ||
this.map.setCenter(center); | ||
} | ||
if (zoom) { | ||
this.map.setZoom(zoom); | ||
} | ||
} | ||
}; | ||
WebMap.prototype._addLayerProviders = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var e_1, _a, e_2, _b, _c, _d, kit, adapters, adapters_1, adapters_1_1, adapter, newAdapter, e_2_1, e_1_1, er_2; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
_e.trys.push([0, 26, , 27]); | ||
_e.label = 1; | ||
case 1: | ||
_e.trys.push([1, 19, 20, 25]); | ||
_c = __asyncValues(this._starterKits.filter(function (x) { return x.getLayerAdapters; })); | ||
_e.label = 2; | ||
case 2: return [4, _c.next()]; | ||
case 3: | ||
if (!(_d = _e.sent(), !_d.done)) return [3, 18]; | ||
kit = _d.value; | ||
return [4, kit.getLayerAdapters.call(kit)]; | ||
case 4: | ||
adapters = _e.sent(); | ||
if (!adapters) return [3, 17]; | ||
_e.label = 5; | ||
case 5: | ||
_e.trys.push([5, 11, 12, 17]); | ||
adapters_1 = __asyncValues(adapters); | ||
_e.label = 6; | ||
case 6: return [4, adapters_1.next()]; | ||
case 7: | ||
if (!(adapters_1_1 = _e.sent(), !adapters_1_1.done)) return [3, 10]; | ||
adapter = adapters_1_1.value; | ||
return [4, adapter.createAdapter(this.map)]; | ||
case 8: | ||
newAdapter = _e.sent(); | ||
if (newAdapter) { | ||
this.map.layerAdapters[adapter.name] = newAdapter; | ||
} | ||
_e.label = 9; | ||
case 9: return [3, 6]; | ||
case 10: return [3, 17]; | ||
case 11: | ||
e_2_1 = _e.sent(); | ||
e_2 = { error: e_2_1 }; | ||
return [3, 17]; | ||
case 12: | ||
_e.trys.push([12, , 15, 16]); | ||
if (!(adapters_1_1 && !adapters_1_1.done && (_b = adapters_1.return))) return [3, 14]; | ||
return [4, _b.call(adapters_1)]; | ||
case 13: | ||
_e.sent(); | ||
_e.label = 14; | ||
case 14: return [3, 16]; | ||
case 15: | ||
if (e_2) throw e_2.error; | ||
return [7]; | ||
case 16: return [7]; | ||
case 17: return [3, 2]; | ||
case 18: return [3, 25]; | ||
case 19: | ||
e_1_1 = _e.sent(); | ||
e_1 = { error: e_1_1 }; | ||
return [3, 25]; | ||
case 20: | ||
_e.trys.push([20, , 23, 24]); | ||
if (!(_d && !_d.done && (_a = _c.return))) return [3, 22]; | ||
return [4, _a.call(_c)]; | ||
case 21: | ||
_e.sent(); | ||
_e.label = 22; | ||
case 22: return [3, 24]; | ||
case 23: | ||
if (e_1) throw e_1.error; | ||
return [7]; | ||
case 24: return [7]; | ||
case 25: return [3, 27]; | ||
case 26: | ||
er_2 = _e.sent(); | ||
throw new Error(er_2); | ||
case 27: return [2]; | ||
} | ||
}); | ||
}); | ||
}; | ||
WebMap.prototype._addEventsListeners = function () { | ||
var _this = this; | ||
this.map.emitter.on('click', function (ev) { return _this._onMapClick(ev); }); | ||
}; | ||
WebMap.prototype._onMapClick = function (ev) { | ||
var _this = this; | ||
this.emitter.emit('click', ev); | ||
this._starterKits.forEach(function (x) { | ||
if (x.onMapClick) { | ||
x.onMapClick(ev, _this); | ||
} | ||
}); | ||
}; | ||
return WebMap; | ||
}()); | ||
function buildWebMap(appOpt, mapOpt) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var webMap; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
webMap = new WebMap(appOpt); | ||
return [4, webMap.create(mapOpt)]; | ||
case 1: | ||
_a.sent(); | ||
return [2, webMap]; | ||
} | ||
}); | ||
}); | ||
} | ||
window.buildWebMap = buildWebMap; | ||
exports.WebMap = WebMap; | ||
exports.buildWebMap = buildWebMap; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=webmap.js.map | ||
!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}); | ||
//# sourceMappingURL=webmap.js.map |
{ | ||
"name": "@nextgis/webmap", | ||
"version": "0.4.12", | ||
"version": "0.5.0", | ||
"description": "", | ||
"main": "lib/webmap.js", | ||
"types": "lib/webmap.d.ts", | ||
"dependencies": { | ||
"@types/geojson": "^7946.0.4", | ||
"events": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/events": "^1.2.0", | ||
"@types/node": "^10.12.1", | ||
"lerna": "^3.4.3", | ||
"rollup": "*", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-node-builtins": "^2.1.2", | ||
"rollup-plugin-node-resolve": "^3.4.0", | ||
"rollup-plugin-sourcemaps": "^0.4.2", | ||
"rollup-plugin-typescript2": "^0.17.2", | ||
"rollup-plugin-uglify": "^6.0.0", | ||
"@types/node": "^10.12.8", | ||
"rimraf": "^2.6.2", | ||
"ts-loader": "^5.3.0", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.4" | ||
"tslint-loader": "^3.6.0", | ||
"tslint-webpack-plugin": "^1.2.2", | ||
"typescript": "^3.1.6", | ||
"webpack": "^4.25.1", | ||
"webpack-cli": "^3.1.2" | ||
}, | ||
"scripts": { | ||
"build": "rollup -c rollup.config.js", | ||
"watch": "rollup -c rollup.config.js -w", | ||
"mjs": "tsc -d --outDir ./lib/modules", | ||
"start": "webpack-dev-server --progress --open --hot", | ||
"clean": "rimraf ./lib", | ||
"dev": "npm run clean && webpack --config ./webpack.config.js --progress", | ||
"build": "npm run dev -- --mode=production", | ||
"prod": "npm run build", | ||
"watch": "echo \"No watch for this app\" && exit 0", | ||
"test": "echo \"Error: run tests from root\" && exit 1" | ||
@@ -42,6 +49,3 @@ }, | ||
"license": "GPL-3.0", | ||
"gitHead": "7c70bda1f937eb3a30c604d59f455f9f0b08f463", | ||
"dependencies": { | ||
"@types/geojson": "^7946.0.4" | ||
} | ||
"gitHead": "f0d00988317d1ac3c032d298f9065e1f90c10368" | ||
} |
@@ -5,6 +5,28 @@ # WebMap | ||
## Commercial support | ||
This library is not intended for using directly in the browser. | ||
Need to fix a bug or add a feature to NextGIS Web? We provide custom development and support for this software. [Contact us](http://nextgis.com/contact/) to discuss options! | ||
Use Webmap with NPM installation method for building large scale applications. It pairs nicely with module bundlers such as [Webpack](https://webpack.js.org/) | ||
```bash | ||
# latest stable | ||
$ npm install --save-dev @nextgis/webmap | ||
# or | ||
$ yarn add @nextgis/webmap | ||
``` | ||
```js | ||
import WebMap from '@nextgis/webmap'; | ||
import LeafletMapAdapter from '@nextgis/leaflet-map-adapter'; | ||
// manually added styles | ||
import 'leaflet/dist/leaflet.css'; | ||
const webMap = new WebMap({ | ||
mapAdapter: new LeafletMapAdapter() | ||
}); | ||
webMap.create(options).then(() => { | ||
// on webmap create | ||
}) | ||
``` | ||
## Commercial support | ||
@@ -11,0 +33,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
10
2
36
124125
2
26
556
3
1
+ Addedevents@^3.0.0
+ Addedevents@3.3.0(transitive)