Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/*!*********************************!*\
!*** ./layers/LayerBaseSpec.js ***!
\*********************************/
/***/ function(module, exports, __webpack_require__) {
/**
* Created by glenn on 3/8/2017.
*/
"use strict";
var LayerBase_1 = __webpack_require__(/*! ../../dist/layers/LayerBase */ 3);
describe("Layer Base", function () {
it('exists', function () {
expect(LayerBase_1.LayerBase).toBeDefined();
});
});
/***/ },
/* 1 */,
/* 2 */,
/* 3 */
/*!***********************************!*\
!*** ../dist/layers/LayerBase.js ***!
\***********************************/
/***/ function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var zoomResolutionConvert = __webpack_require__(/*! ../olHelpers/zoomResolutionConvert */ 4);
var provide_1 = __webpack_require__(/*! ../util/provide */ 5);
var makeGuid_1 = __webpack_require__(/*! ../util/makeGuid */ 6);
var $ = __webpack_require__(/*! jquery */ 7);
var nm = provide_1.default('layers');
/**
* The base layer class
* @abstract
*/
var LayerBase = (function () {
/**
* The base layer for all others
* @param {string} url - url for source
* @param {object} options - config
* @param {string} [options.id=makeGuid()] - layer id
* @param {string} [options.name=Unnamed Layer] - layer name
* @param {number} [options.opacity=1] - opacity
* @param {boolean} [options.visible=true] - default visible
* @param {number} [options.minZoom=undefined] - min zoom level, 0 - 28
* @param {number} [options.maxZoom=undefined] - max zoom level, 0 - 28
* @param {object} [options.params={}] - the get parameters to include to retrieve the layer
* @param {number} [options.zIndex=0] - the z index for the layer
* @param {function} [options.loadCallback] - function to call on load, context this is the layer object
* @param {boolean} [options.legendCollapse=false] - if the legend item should be initially collapsed
* @param {boolean} [options.legendCheckbox=true] - if the legend item should have a checkbox for visibility
* @param {boolean} [options.legendContent=undefined] - additional content to add to the legend
*/
function LayerBase(url, options) {
if (options === void 0) { options = {}; }
options = options || {};
if (typeof url !== 'string') {
throw 'Invalid URL';
}
this._url = url;
this._params = typeof options.params == 'object' ? options.params : {};
this._legendCollapse = typeof options.legendCollapse == 'boolean' ? options.legendCollapse : false;
this._legendCheckbox = typeof options.legendCheckbox == 'boolean' ? options.legendCheckbox : true;
this.id = options.id || makeGuid_1.default();
this._name = options.name || 'Unnamed Layer';
this.animate = false;
this._opacity = typeof options.opacity == 'number' ? options.opacity : 1;
if (this._opacity > 1) {
this._opacity = 1;
}
else if (this._opacity < 0) {
this._opacity = 0;
}
this._visible = typeof options.visible === 'boolean' ? options.visible : true;
this._source = undefined;
/**
*
* @protected
*/
this._olLayer = undefined;
this._loaded = false;
this._maxResolution = zoomResolutionConvert.zoomToResolution(options.minZoom);
if (typeof this._maxResolution !== 'undefined') {
this._maxResolution += 0.00001;
}
this._minResolution = zoomResolutionConvert.zoomToResolution(options.maxZoom);
this._minZoom = typeof options.minZoom == 'number' ? options.minZoom : undefined;
this._maxZoom = typeof options.maxZoom == 'number' ? options.maxZoom : undefined;
this._zIndex = typeof options.zIndex == 'number' ? options.zIndex : 0;
this.loadCallback = typeof options.loadCallback == 'function' ? options.loadCallback : function () {
};
this._legendContent = '';
if (this._legendCheckbox) {
this._legendContent += "<input type=\"checkbox\" " + (this.visible ? 'checked' : '') + " " +
("class=\"legend-check\" id=\"" + this.id + "-legend-layer-check\"><span></span>");
this._legendContent += "<label for=\"" + this.id + "-legend-layer-check\" class=\"legend-layer-name\">" + this.name + "</label>";
}
else {
this._legendContent += "<label class=\"legend-layer-name\">" + this.name + "</label>";
}
this._$legendDiv = null;
this._applyCollapseCalled = false;
this._addLegendContent(typeof options.legendContent === 'string' ? options.legendContent : undefined);
}
/**
* base load function, sets _loaded = true if it is not already
* @protected
* @returns {boolean} if already loaded
*/
LayerBase.prototype._load = function () {
if (this.loaded == true) {
return true;
}
else {
this._loaded = true;
return false;
}
};
/**
* Get the legend html, be sure to only add to the DOM once
* @returns {string} html for layer wrapped in a div
*/
LayerBase.prototype.getLegendDiv = function () {
return "<div class=\"legend-layer-div\" id=\"" + this.id + "-legend-layer-div\">" + this._legendContent + "</div>";
};
/**
*
* @param additionalContent - additional content to add to legend
* @private
*/
LayerBase.prototype._addLegendContent = function (additionalContent) {
if (additionalContent === void 0) { additionalContent = ''; }
var addCollapse = additionalContent.indexOf('<ul>') > -1;
if (addCollapse) {
additionalContent = '<span class="legend-items-expander" title="Expand/Collapse">▼</span>' + additionalContent;
}
this._legendContent += additionalContent;
this._$legendDiv = $("#" + this.id + "-legend-layer-div");
if (this._$legendDiv.length > 0) {
this._$legendDiv.append(additionalContent);
this.applyCollapse();
}
};
/**
* add additional content to the legend
* @param {string} [additionalContent=] - additonal content to add
*/
LayerBase.prototype.addLegendContent = function (additionalContent) {
this._addLegendContent(additionalContent);
};
LayerBase.prototype.applyCollapse = function () {
if (this._applyCollapseCalled) {
console.log('collapse already applied');
return undefined;
}
this._$legendDiv = $("#" + this.id + "-legend-layer-div");
if (this._$legendDiv.length > 0) {
var $expander = this._$legendDiv.find('.legend-items-expander');
if ($expander.length > 0) {
this._applyCollapseCalled = true;
$expander.click(function () {
var $this = $(this);
$this.siblings('ul').slideToggle();
if ($this.hasClass('legend-layer-group-collapsed')) {
$this.removeClass('legend-layer-group-collapsed');
$this.html('▼');
}
else {
$this.addClass('legend-layer-group-collapsed');
$this.html('▶');
}
});
if (this._legendCollapse) {
$expander.trigger('click');
}
}
}
};
/**
* trick to refresh the layer
*/
LayerBase.prototype.refresh = function () {
if (this.source) {
this.source.refresh();
}
};
Object.defineProperty(LayerBase.prototype, "id", {
get: function () {
return this._id;
},
set: function (newId) {
this._id = newId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "animate", {
get: function () {
return this._animate;
},
set: function (animate) {
this._animate = animate;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "legendContent", {
/**
* get the legend content
* @type {string}
*/
get: function () {
return this._legendContent;
},
/**
* set the legend content directly
* @param {string} newVal - new content
* @protected
*/
set: function (newVal) {
this._legendContent = newVal;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "params", {
/**
* get the map get params
* @type {object}
*/
get: function () {
return this._params;
},
/**
* set the map get params
* @param {object} newParams - new get params
* @protected
*/
set: function (newParams) {
this._params = newParams;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "minResolution", {
/**
* get the minimum resolution
* @type {number|*}
*/
get: function () {
return this._minResolution;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "maxResolution", {
/**
* get the maximum resolution
* @type {number|*}
*/
get: function () {
return this._maxResolution;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "minZoom", {
/**
* get min zoom
* @type {number|*}
*/
get: function () {
return this._minZoom;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "maxZoom", {
/**
* get max zoom
* @type {number|*}
*/
get: function () {
return this._maxZoom;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "url", {
/**
* get the url
* @type {string}
*/
get: function () {
return this._url;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "visible", {
/**
* Get the layer visibility
* @type {boolean}
*/
get: function () {
return this._visible;
},
/**
* set the visibility
* @param visibility
*/
set: function (visibility) {
this.setVisible(visibility);
},
enumerable: true,
configurable: true
});
LayerBase.prototype.setVisible = function (visibility) {
this._visible = visibility;
if (this.olLayer) {
this.olLayer.setVisible(this._visible);
if (visibility && !this._loaded) {
this._load();
}
}
};
Object.defineProperty(LayerBase.prototype, "opacity", {
/**
* Get the layer opacity
* @type {number}
*/
get: function () {
return this._opacity;
},
/**
* Set the layer opacity
* @param {number} opacity - layer opacity
*/
set: function (opacity) {
this._opacity = opacity;
if (this.olLayer) {
this.olLayer.setOpacity(this._opacity);
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "name", {
/**
* Get the layer name
* @type {string}
*/
get: function () {
return this._name;
},
/**
* set the layer name
* @param {string} newName - the new name
*/
set: function (newName) {
this._name = newName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "loaded", {
/**
* Check if the layer is loaded
* @type {boolean}
*/
get: function () {
return this._loaded;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LayerBase.prototype, "source", {
/**
* get the layer source
* @type {*}
*/
get: function () {
return this.getSource();
},
enumerable: true,
configurable: true
});
LayerBase.prototype.getSource = function () {
return this._source;
};
Object.defineProperty(LayerBase.prototype, "zIndex", {
/**
* get the z index
*/
get: function () {
return this._zIndex;
},
/**
* set the z index
*/
set: function (newZ) {
this._zIndex = newZ;
},
enumerable: true,
configurable: true
});
LayerBase.prototype.setZIndex = function (newZ) {
};
Object.defineProperty(LayerBase.prototype, "olLayer", {
/**
* the the ol layer
*/
get: function () {
return this.getOlLayer();
},
enumerable: true,
configurable: true
});
LayerBase.prototype.getOlLayer = function () {
return this._olLayer;
};
return LayerBase;
}());
exports.LayerBase = LayerBase;
nm.LayerBase = LayerBase;
exports.default = LayerBase;
/***/ },
/* 4 */
/*!**************************************************!*\
!*** ../dist/olHelpers/zoomResolutionConvert.js ***!
\**************************************************/
/***/ function(module, exports, __webpack_require__) {
/**
* Created by gavorhes on 12/14/2015.
*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var provide_1 = __webpack_require__(/*! ../util/provide */ 5);
var nm = provide_1.default('olHelpers.zoomResolutionConvert');
var _zoomResLookup = [
156543.03392804097,
78271.51696402048,
39135.75848201024,
19567.87924100512,
9783.93962050256,
4891.96981025128,
2445.98490512564,
1222.99245256282,
611.49622628141,
305.748113140705,
152.8740565703525,
76.43702828517625,
38.21851414258813,
19.109257071294063,
9.554628535647032,
4.777314267823516,
2.388657133911758,
1.194328566955879,
0.5971642834779395,
0.29858214173896974,
0.14929107086948487,
0.07464553543474244,
0.03732276771737122,
0.01866138385868561,
0.009330691929342804,
0.004665345964671402,
0.002332672982335701,
0.0011663364911678506,
0.0005831682455839253 //28
];
/**
* Get the resolution given the zoom level
* @param {number} zoomLevel - the zoom level
* @returns {number|*} the map resolution
*/
function zoomToResolution(zoomLevel) {
"use strict";
if (typeof zoomLevel == 'number') {
if (zoomLevel % 1 === 0 && zoomLevel >= 0 && zoomLevel <= 28) {
return _zoomResLookup[zoomLevel];
}
else {
console.log("invalid zoom level provided: " + zoomLevel);
return undefined;
}
}
else {
return undefined;
}
}
exports.zoomToResolution = zoomToResolution;
nm.zoomToResolution = zoomToResolution;
/**
* Get resolution from the zoom level
* @param {number} resolution - the resolution
* @returns {number|*} the zoom level
*/
function resolutionToZoom(resolution) {
for (var i = 0; i < _zoomResLookup.length; i++) {
if (resolution >= _zoomResLookup[i]) {
return i;
}
}
return 0;
}
exports.resolutionToZoom = resolutionToZoom;
nm.resolutionToZoom = resolutionToZoom;
/***/ },
/* 5 */
/*!*******************************!*\
!*** ../dist/util/provide.js ***!
\*******************************/
/***/ function(module, exports) {
/**
* Created by gavorhes on 12/10/2015.
*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* create a namespace on the gv object
* @param {string} namespace to create
* @returns {object} object representing the namespace
*/
function provide(namespace) {
"use strict";
if (typeof window['gv'] == 'undefined') {
window['gv'] = {};
}
var parts = namespace.split('.');
var nameSpace = window['gv'];
for (var i = 0; i < parts.length; i++) {
var newObject = nameSpace[parts[i]];
if (typeof newObject == 'undefined') {
nameSpace[parts[i]] = {};
}
nameSpace = nameSpace[parts[i]];
}
return nameSpace;
}
provide('util');
window['gv'].util.provide = provide;
exports.default = provide;
/***/ },
/* 6 */
/*!********************************!*\
!*** ../dist/util/makeGuid.js ***!
\********************************/
/***/ function(module, exports, __webpack_require__) {
/**
* Created by gavorhes on 11/3/2015.
*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var provide_1 = __webpack_require__(/*! ./provide */ 5);
var nm = provide_1.default('util');
/**
* guids are used to uniquely identify groups and features
* @returns {string} a new guid
*/
function makeGuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : r & 0x3 | 0x8;
return v.toString(16);
});
}
nm.makeGuid = makeGuid;
exports.default = makeGuid;
/***/ },
/* 7 */
/*!********************!*\
!*** external "$" ***!
\********************/
/***/ function(module, exports) {
module.exports = $;
/***/ }
/******/ ]);
//# sourceMappingURL=LayerBaseSpec.js.map