@nextgis/leaflet-map-adapter 1.16.9 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/leaflet-map-adapter.esm-browser.js +1663 -1774
- package/lib/leaflet-map-adapter.esm-browser.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js +3 -3
- package/lib/leaflet-map-adapter.esm-browser.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.js +1624 -1735
- package/lib/leaflet-map-adapter.esm-bundler.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.prod.js +2 -2
- package/lib/leaflet-map-adapter.esm-bundler.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.global.js +1665 -1659
- package/lib/leaflet-map-adapter.global.js.map +1 -1
- package/lib/leaflet-map-adapter.global.prod.js +3 -3
- package/lib/leaflet-map-adapter.global.prod.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 1.17.0; author: NextGIS */
|
|
2
2
|
var LeafletMapAdapter = (function () {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -16,7 +16,7 @@ var LeafletMapAdapter = (function () {
|
|
|
16
16
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
17
|
PERFORMANCE OF THIS SOFTWARE.
|
|
18
18
|
***************************************************************************** */
|
|
19
|
-
/* global Reflect, Promise */
|
|
19
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
20
20
|
|
|
21
21
|
var extendStatics = function(d, b) {
|
|
22
22
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -72,7 +72,7 @@ var LeafletMapAdapter = (function () {
|
|
|
72
72
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
73
73
|
function step(op) {
|
|
74
74
|
if (f) throw new TypeError("Generator is already executing.");
|
|
75
|
-
while (_) try {
|
|
75
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
76
76
|
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;
|
|
77
77
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
78
78
|
switch (op[0]) {
|
|
@@ -102,7 +102,12 @@ var LeafletMapAdapter = (function () {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
105
|
-
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
108
|
+
var e = new Error(message);
|
|
109
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
110
|
+
};
|
|
106
111
|
|
|
107
112
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
108
113
|
|
|
@@ -14646,1703 +14651,1704 @@ var LeafletMapAdapter = (function () {
|
|
|
14646
14651
|
|
|
14647
14652
|
} (leafletSrc, leafletSrc.exports));
|
|
14648
14653
|
|
|
14649
|
-
function convertMapClickEvent(evt) {
|
|
14650
|
-
var coord = evt.containerPoint;
|
|
14651
|
-
var latLng = evt.latlng;
|
|
14652
|
-
var lat = latLng.lat, lng = latLng.lng;
|
|
14653
|
-
return {
|
|
14654
|
-
latLng: latLng,
|
|
14655
|
-
lngLat: [lng, lat],
|
|
14656
|
-
pixel: { left: coord.x, top: coord.y },
|
|
14657
|
-
source: evt,
|
|
14658
|
-
};
|
|
14654
|
+
function convertMapClickEvent(evt) {
|
|
14655
|
+
var coord = evt.containerPoint;
|
|
14656
|
+
var latLng = evt.latlng;
|
|
14657
|
+
var lat = latLng.lat, lng = latLng.lng;
|
|
14658
|
+
return {
|
|
14659
|
+
latLng: latLng,
|
|
14660
|
+
lngLat: [lng, lat],
|
|
14661
|
+
pixel: { left: coord.x, top: coord.y },
|
|
14662
|
+
source: evt,
|
|
14663
|
+
};
|
|
14659
14664
|
}
|
|
14660
14665
|
|
|
14661
|
-
function createControl(control, options, map) {
|
|
14662
|
-
if (options === void 0) { options = {}; }
|
|
14663
|
-
var C = leafletSrc.exports.Control.extend({
|
|
14664
|
-
onAdd: function () {
|
|
14665
|
-
var element = document.createElement('div');
|
|
14666
|
-
var content = control.onAdd(map);
|
|
14667
|
-
element.classList.add('leaflet-control');
|
|
14668
|
-
if (options.bar) {
|
|
14669
|
-
element.classList.add('leaflet-bar');
|
|
14670
|
-
}
|
|
14671
|
-
if (options.addClass) {
|
|
14672
|
-
element.classList.add(options.addClass);
|
|
14673
|
-
}
|
|
14674
|
-
if (!options.margin && !options.bar) {
|
|
14675
|
-
element.style.marginBottom = '0px';
|
|
14676
|
-
element.style.marginTop = '0px';
|
|
14677
|
-
element.style.marginLeft = '0px';
|
|
14678
|
-
element.style.marginRight = '0px';
|
|
14679
|
-
}
|
|
14680
|
-
if (content) {
|
|
14681
|
-
element.appendChild(content);
|
|
14682
|
-
}
|
|
14683
|
-
leafletSrc.exports.DomEvent.disableClickPropagation(element);
|
|
14684
|
-
return element;
|
|
14685
|
-
},
|
|
14686
|
-
onRemove: function () {
|
|
14687
|
-
control.onRemove();
|
|
14688
|
-
},
|
|
14689
|
-
});
|
|
14690
|
-
return new C();
|
|
14666
|
+
function createControl(control, options, map) {
|
|
14667
|
+
if (options === void 0) { options = {}; }
|
|
14668
|
+
var C = leafletSrc.exports.Control.extend({
|
|
14669
|
+
onAdd: function () {
|
|
14670
|
+
var element = document.createElement('div');
|
|
14671
|
+
var content = control.onAdd(map);
|
|
14672
|
+
element.classList.add('leaflet-control');
|
|
14673
|
+
if (options.bar) {
|
|
14674
|
+
element.classList.add('leaflet-bar');
|
|
14675
|
+
}
|
|
14676
|
+
if (options.addClass) {
|
|
14677
|
+
element.classList.add(options.addClass);
|
|
14678
|
+
}
|
|
14679
|
+
if (!options.margin && !options.bar) {
|
|
14680
|
+
element.style.marginBottom = '0px';
|
|
14681
|
+
element.style.marginTop = '0px';
|
|
14682
|
+
element.style.marginLeft = '0px';
|
|
14683
|
+
element.style.marginRight = '0px';
|
|
14684
|
+
}
|
|
14685
|
+
if (content) {
|
|
14686
|
+
element.appendChild(content);
|
|
14687
|
+
}
|
|
14688
|
+
leafletSrc.exports.DomEvent.disableClickPropagation(element);
|
|
14689
|
+
return element;
|
|
14690
|
+
},
|
|
14691
|
+
onRemove: function () {
|
|
14692
|
+
control.onRemove();
|
|
14693
|
+
},
|
|
14694
|
+
});
|
|
14695
|
+
return new C();
|
|
14691
14696
|
}
|
|
14692
14697
|
|
|
14693
|
-
function createButtonControl(options, map) {
|
|
14694
|
-
var link = document.createElement('a');
|
|
14695
|
-
var title = options.title || '';
|
|
14696
|
-
link.href = '#';
|
|
14697
|
-
link.title = title;
|
|
14698
|
-
link.setAttribute('role', 'button');
|
|
14699
|
-
link.setAttribute('aria-label', title);
|
|
14700
|
-
if (options.addClass) {
|
|
14701
|
-
link.classList.add(options.addClass);
|
|
14702
|
-
}
|
|
14703
|
-
leafletSrc.exports.DomEvent.disableClickPropagation(link);
|
|
14704
|
-
leafletSrc.exports.DomEvent.on(link, 'click', leafletSrc.exports.DomEvent.stop);
|
|
14705
|
-
if (options.html instanceof HTMLElement) {
|
|
14706
|
-
link.appendChild(options.html);
|
|
14707
|
-
}
|
|
14708
|
-
else if (typeof options.html === 'string') {
|
|
14709
|
-
link.innerHTML = options.html;
|
|
14710
|
-
}
|
|
14711
|
-
var onClick = function (e) {
|
|
14712
|
-
e.stopPropagation();
|
|
14713
|
-
options.onClick();
|
|
14714
|
-
};
|
|
14715
|
-
return createControl({
|
|
14716
|
-
onAdd: function () {
|
|
14717
|
-
if (options.onClick !== undefined) {
|
|
14718
|
-
link.addEventListener('click', onClick);
|
|
14719
|
-
}
|
|
14720
|
-
return link;
|
|
14721
|
-
},
|
|
14722
|
-
onRemove: function () {
|
|
14723
|
-
var parent = link.parentNode;
|
|
14724
|
-
if (parent) {
|
|
14725
|
-
parent.removeChild(link);
|
|
14726
|
-
}
|
|
14727
|
-
if (options.onClick !== undefined) {
|
|
14728
|
-
link.removeEventListener('click', onClick);
|
|
14729
|
-
}
|
|
14730
|
-
},
|
|
14731
|
-
}, { bar: true }, map);
|
|
14698
|
+
function createButtonControl(options, map) {
|
|
14699
|
+
var link = document.createElement('a');
|
|
14700
|
+
var title = options.title || '';
|
|
14701
|
+
link.href = '#';
|
|
14702
|
+
link.title = title;
|
|
14703
|
+
link.setAttribute('role', 'button');
|
|
14704
|
+
link.setAttribute('aria-label', title);
|
|
14705
|
+
if (options.addClass) {
|
|
14706
|
+
link.classList.add(options.addClass);
|
|
14707
|
+
}
|
|
14708
|
+
leafletSrc.exports.DomEvent.disableClickPropagation(link);
|
|
14709
|
+
leafletSrc.exports.DomEvent.on(link, 'click', leafletSrc.exports.DomEvent.stop);
|
|
14710
|
+
if (options.html instanceof HTMLElement) {
|
|
14711
|
+
link.appendChild(options.html);
|
|
14712
|
+
}
|
|
14713
|
+
else if (typeof options.html === 'string') {
|
|
14714
|
+
link.innerHTML = options.html;
|
|
14715
|
+
}
|
|
14716
|
+
var onClick = function (e) {
|
|
14717
|
+
e.stopPropagation();
|
|
14718
|
+
options.onClick();
|
|
14719
|
+
};
|
|
14720
|
+
return createControl({
|
|
14721
|
+
onAdd: function () {
|
|
14722
|
+
if (options.onClick !== undefined) {
|
|
14723
|
+
link.addEventListener('click', onClick);
|
|
14724
|
+
}
|
|
14725
|
+
return link;
|
|
14726
|
+
},
|
|
14727
|
+
onRemove: function () {
|
|
14728
|
+
var parent = link.parentNode;
|
|
14729
|
+
if (parent) {
|
|
14730
|
+
parent.removeChild(link);
|
|
14731
|
+
}
|
|
14732
|
+
if (options.onClick !== undefined) {
|
|
14733
|
+
link.removeEventListener('click', onClick);
|
|
14734
|
+
}
|
|
14735
|
+
},
|
|
14736
|
+
}, { bar: true }, map);
|
|
14732
14737
|
}
|
|
14733
14738
|
|
|
14734
|
-
var AttributionControl = /** @class */ (function (_super) {
|
|
14735
|
-
__extends(AttributionControl, _super);
|
|
14736
|
-
// options: AttributionControlOptions
|
|
14737
|
-
function AttributionControl(options) {
|
|
14738
|
-
var _this = _super.call(this, options) || this;
|
|
14739
|
-
var customAttribution = options && options.customAttribution;
|
|
14740
|
-
if (customAttribution) {
|
|
14741
|
-
var attributions = [];
|
|
14742
|
-
if (Array.isArray(customAttribution)) {
|
|
14743
|
-
attributions = customAttribution;
|
|
14744
|
-
}
|
|
14745
|
-
else if (customAttribution) {
|
|
14746
|
-
attributions = [customAttribution];
|
|
14747
|
-
}
|
|
14748
|
-
attributions.forEach(function (x) { return _this.addAttribution(x); });
|
|
14749
|
-
}
|
|
14750
|
-
return _this;
|
|
14751
|
-
}
|
|
14752
|
-
return AttributionControl;
|
|
14739
|
+
var AttributionControl = /** @class */ (function (_super) {
|
|
14740
|
+
__extends(AttributionControl, _super);
|
|
14741
|
+
// options: AttributionControlOptions
|
|
14742
|
+
function AttributionControl(options) {
|
|
14743
|
+
var _this = _super.call(this, options) || this;
|
|
14744
|
+
var customAttribution = options && options.customAttribution;
|
|
14745
|
+
if (customAttribution) {
|
|
14746
|
+
var attributions = [];
|
|
14747
|
+
if (Array.isArray(customAttribution)) {
|
|
14748
|
+
attributions = customAttribution;
|
|
14749
|
+
}
|
|
14750
|
+
else if (customAttribution) {
|
|
14751
|
+
attributions = [customAttribution];
|
|
14752
|
+
}
|
|
14753
|
+
attributions.forEach(function (x) { return _this.addAttribution(x); });
|
|
14754
|
+
}
|
|
14755
|
+
return _this;
|
|
14756
|
+
}
|
|
14757
|
+
return AttributionControl;
|
|
14753
14758
|
}(leafletSrc.exports.Control.Attribution));
|
|
14754
14759
|
|
|
14755
|
-
/**
|
|
14756
|
-
* from https://github.com/CesiumGS/cesium/blob/master/Source/Core/defined.js
|
|
14757
|
-
*
|
|
14758
|
-
* @param val - The object.
|
|
14759
|
-
* @returns Returns true if the object is defined, returns false otherwise.
|
|
14760
|
-
*
|
|
14761
|
-
* @example
|
|
14762
|
-
* ```javascript
|
|
14763
|
-
* if (defined(positions)) {
|
|
14764
|
-
* doSomething();
|
|
14765
|
-
* } else {
|
|
14766
|
-
* doSomethingElse();
|
|
14767
|
-
* }
|
|
14768
|
-
* ```
|
|
14769
|
-
*/
|
|
14770
|
-
function defined(val) {
|
|
14771
|
-
return val !== undefined && val !== null;
|
|
14760
|
+
/**
|
|
14761
|
+
* from https://github.com/CesiumGS/cesium/blob/master/Source/Core/defined.js
|
|
14762
|
+
*
|
|
14763
|
+
* @param val - The object.
|
|
14764
|
+
* @returns Returns true if the object is defined, returns false otherwise.
|
|
14765
|
+
*
|
|
14766
|
+
* @example
|
|
14767
|
+
* ```javascript
|
|
14768
|
+
* if (defined(positions)) {
|
|
14769
|
+
* doSomething();
|
|
14770
|
+
* } else {
|
|
14771
|
+
* doSomethingElse();
|
|
14772
|
+
* }
|
|
14773
|
+
* ```
|
|
14774
|
+
*/
|
|
14775
|
+
function defined(val) {
|
|
14776
|
+
return val !== undefined && val !== null;
|
|
14772
14777
|
}
|
|
14773
14778
|
|
|
14774
|
-
// based on https://github.com/bvaughn/debounce-decorator
|
|
14775
|
-
function debounce(cb, wait) {
|
|
14776
|
-
if (wait === void 0) { wait = 10; }
|
|
14777
|
-
var timeoutId;
|
|
14778
|
-
function wrapper() {
|
|
14779
|
-
var _this = this;
|
|
14780
|
-
var args = [];
|
|
14781
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
14782
|
-
args[_i] = arguments[_i];
|
|
14783
|
-
}
|
|
14784
|
-
wrapper.clear();
|
|
14785
|
-
timeoutId = setTimeout(function () {
|
|
14786
|
-
timeoutId = null;
|
|
14787
|
-
cb.apply(_this, args);
|
|
14788
|
-
}, wait);
|
|
14789
|
-
}
|
|
14790
|
-
wrapper.clear = function () {
|
|
14791
|
-
if (timeoutId) {
|
|
14792
|
-
clearTimeout(timeoutId);
|
|
14793
|
-
timeoutId = null;
|
|
14794
|
-
}
|
|
14795
|
-
};
|
|
14796
|
-
return wrapper;
|
|
14779
|
+
// based on https://github.com/bvaughn/debounce-decorator
|
|
14780
|
+
function debounce(cb, wait) {
|
|
14781
|
+
if (wait === void 0) { wait = 10; }
|
|
14782
|
+
var timeoutId;
|
|
14783
|
+
function wrapper() {
|
|
14784
|
+
var _this = this;
|
|
14785
|
+
var args = [];
|
|
14786
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
14787
|
+
args[_i] = arguments[_i];
|
|
14788
|
+
}
|
|
14789
|
+
wrapper.clear();
|
|
14790
|
+
timeoutId = setTimeout(function () {
|
|
14791
|
+
timeoutId = null;
|
|
14792
|
+
cb.apply(_this, args);
|
|
14793
|
+
}, wait);
|
|
14794
|
+
}
|
|
14795
|
+
wrapper.clear = function () {
|
|
14796
|
+
if (timeoutId) {
|
|
14797
|
+
clearTimeout(timeoutId);
|
|
14798
|
+
timeoutId = null;
|
|
14799
|
+
}
|
|
14800
|
+
};
|
|
14801
|
+
return wrapper;
|
|
14797
14802
|
}
|
|
14798
14803
|
|
|
14799
|
-
function isPaint(paint) {
|
|
14800
|
-
if (Object.prototype.toString.call(paint) === '[object Object]') {
|
|
14801
|
-
return true;
|
|
14802
|
-
}
|
|
14803
|
-
return false;
|
|
14804
|
-
}
|
|
14805
|
-
function isPaintCallback(paint) {
|
|
14806
|
-
if (typeof paint === 'function') {
|
|
14807
|
-
return true;
|
|
14808
|
-
}
|
|
14809
|
-
return false;
|
|
14804
|
+
function isPaint(paint) {
|
|
14805
|
+
if (Object.prototype.toString.call(paint) === '[object Object]') {
|
|
14806
|
+
return true;
|
|
14807
|
+
}
|
|
14808
|
+
return false;
|
|
14810
14809
|
}
|
|
14811
|
-
|
|
14812
|
-
|
|
14813
|
-
|
|
14814
|
-
|
|
14815
|
-
return
|
|
14810
|
+
function isPaintCallback(paint) {
|
|
14811
|
+
if (typeof paint === 'function') {
|
|
14812
|
+
return true;
|
|
14813
|
+
}
|
|
14814
|
+
return false;
|
|
14816
14815
|
}
|
|
14817
14816
|
|
|
14818
|
-
|
|
14819
|
-
|
|
14820
|
-
|
|
14821
|
-
|
|
14822
|
-
Polygon: 'polygon',
|
|
14823
|
-
MultiLineString: 'line',
|
|
14824
|
-
MultiPolygon: 'polygon',
|
|
14825
|
-
GeometryCollection: 'polygon',
|
|
14826
|
-
};
|
|
14827
|
-
var PAINT = {
|
|
14828
|
-
stroke: false,
|
|
14829
|
-
opacity: 1,
|
|
14830
|
-
};
|
|
14831
|
-
var backAliases = {};
|
|
14832
|
-
for (var a in typeAlias) {
|
|
14833
|
-
var layerType = typeAlias[a];
|
|
14834
|
-
var backAlias = backAliases[layerType] || [];
|
|
14835
|
-
backAlias.push(a);
|
|
14836
|
-
backAliases[layerType] = backAlias;
|
|
14837
|
-
}
|
|
14838
|
-
function geometryFilter(geometry, type) {
|
|
14839
|
-
var geoJsonGeometry = backAliases[type] || [];
|
|
14840
|
-
return geoJsonGeometry.indexOf(geometry) !== -1;
|
|
14841
|
-
}
|
|
14842
|
-
function filterGeometries(data, type) {
|
|
14843
|
-
if (data.type === 'FeatureCollection') {
|
|
14844
|
-
var _data = data;
|
|
14845
|
-
_data.features = _data.features.filter(function (f) {
|
|
14846
|
-
return geometryFilter(f.geometry.type, type);
|
|
14847
|
-
});
|
|
14848
|
-
}
|
|
14849
|
-
else if (data.type === 'Feature') {
|
|
14850
|
-
var allow = geometryFilter(data.geometry.type, type);
|
|
14851
|
-
if (!allow) {
|
|
14852
|
-
return false;
|
|
14853
|
-
}
|
|
14854
|
-
}
|
|
14855
|
-
else if (data.type === 'GeometryCollection') {
|
|
14856
|
-
var _data = data;
|
|
14857
|
-
_data.geometries = _data.geometries.filter(function (g) {
|
|
14858
|
-
return geometryFilter(g.type, type);
|
|
14859
|
-
});
|
|
14860
|
-
}
|
|
14861
|
-
return data;
|
|
14862
|
-
}
|
|
14863
|
-
function featuresBounds(features) {
|
|
14864
|
-
var geoJsonLayer = new leafletSrc.exports.GeoJSON();
|
|
14865
|
-
var features_ = Array.isArray(features) ? features : [features];
|
|
14866
|
-
features_.forEach(function (f) { return geoJsonLayer.addData(f); });
|
|
14867
|
-
return geoJsonLayer.getBounds();
|
|
14868
|
-
}
|
|
14869
|
-
function getFeaturesBounds(features) {
|
|
14870
|
-
return boundsToArray(featuresBounds(features));
|
|
14871
|
-
}
|
|
14872
|
-
function getFeaturesCenter(features) {
|
|
14873
|
-
var _a = featuresBounds(features).getCenter(), lat = _a.lat, lng = _a.lng;
|
|
14874
|
-
return [lng, lat];
|
|
14875
|
-
}
|
|
14876
|
-
function createFeaturePositionOptions(features) {
|
|
14877
|
-
return {
|
|
14878
|
-
getBounds: function () { return getFeaturesBounds(features); },
|
|
14879
|
-
getCenter: function () { return getFeaturesCenter(features); },
|
|
14880
|
-
};
|
|
14817
|
+
function boundsToArray(bounds) {
|
|
14818
|
+
var ne = bounds.getNorthEast();
|
|
14819
|
+
var sw = bounds.getSouthWest();
|
|
14820
|
+
return [sw.lng, sw.lat, ne.lng, ne.lat];
|
|
14881
14821
|
}
|
|
14882
14822
|
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14823
|
+
var typeAlias = {
|
|
14824
|
+
Point: 'point',
|
|
14825
|
+
LineString: 'line',
|
|
14826
|
+
MultiPoint: 'point',
|
|
14827
|
+
Polygon: 'polygon',
|
|
14828
|
+
MultiLineString: 'line',
|
|
14829
|
+
MultiPolygon: 'polygon',
|
|
14830
|
+
GeometryCollection: 'polygon',
|
|
14831
|
+
};
|
|
14832
|
+
var PAINT = {
|
|
14833
|
+
stroke: false,
|
|
14834
|
+
opacity: 1,
|
|
14835
|
+
};
|
|
14836
|
+
var backAliases = {};
|
|
14837
|
+
for (var a in typeAlias) {
|
|
14838
|
+
var layerType = typeAlias[a];
|
|
14839
|
+
var backAlias = backAliases[layerType] || [];
|
|
14840
|
+
backAlias.push(a);
|
|
14841
|
+
backAliases[layerType] = backAlias;
|
|
14889
14842
|
}
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
|
|
14902
|
-
|
|
14903
|
-
|
|
14904
|
-
|
|
14905
|
-
|
|
14906
|
-
|
|
14907
|
-
if (
|
|
14908
|
-
var
|
|
14909
|
-
|
|
14910
|
-
|
|
14911
|
-
|
|
14912
|
-
|
|
14913
|
-
|
|
14914
|
-
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
|
|
14918
|
-
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
14843
|
+
function geometryFilter(geometry, type) {
|
|
14844
|
+
var geoJsonGeometry = backAliases[type] || [];
|
|
14845
|
+
return geoJsonGeometry.indexOf(geometry) !== -1;
|
|
14846
|
+
}
|
|
14847
|
+
function filterGeometries(data, type) {
|
|
14848
|
+
if (data.type === 'FeatureCollection') {
|
|
14849
|
+
var _data = data;
|
|
14850
|
+
_data.features = _data.features.filter(function (f) {
|
|
14851
|
+
return geometryFilter(f.geometry.type, type);
|
|
14852
|
+
});
|
|
14853
|
+
}
|
|
14854
|
+
else if (data.type === 'Feature') {
|
|
14855
|
+
var allow = geometryFilter(data.geometry.type, type);
|
|
14856
|
+
if (!allow) {
|
|
14857
|
+
return false;
|
|
14858
|
+
}
|
|
14859
|
+
}
|
|
14860
|
+
else if (data.type === 'GeometryCollection') {
|
|
14861
|
+
var _data = data;
|
|
14862
|
+
_data.geometries = _data.geometries.filter(function (g) {
|
|
14863
|
+
return geometryFilter(g.type, type);
|
|
14864
|
+
});
|
|
14865
|
+
}
|
|
14866
|
+
return data;
|
|
14867
|
+
}
|
|
14868
|
+
function featuresBounds(features) {
|
|
14869
|
+
var geoJsonLayer = new leafletSrc.exports.GeoJSON();
|
|
14870
|
+
var features_ = Array.isArray(features) ? features : [features];
|
|
14871
|
+
features_.forEach(function (f) { return geoJsonLayer.addData(f); });
|
|
14872
|
+
return geoJsonLayer.getBounds();
|
|
14873
|
+
}
|
|
14874
|
+
function getFeaturesBounds(features) {
|
|
14875
|
+
return boundsToArray(featuresBounds(features));
|
|
14876
|
+
}
|
|
14877
|
+
function getFeaturesCenter(features) {
|
|
14878
|
+
var _a = featuresBounds(features).getCenter(), lat = _a.lat, lng = _a.lng;
|
|
14879
|
+
return [lng, lat];
|
|
14880
|
+
}
|
|
14881
|
+
function createFeaturePositionOptions(features) {
|
|
14882
|
+
return {
|
|
14883
|
+
getBounds: function () { return getFeaturesBounds(features); },
|
|
14884
|
+
getCenter: function () { return getFeaturesCenter(features); },
|
|
14885
|
+
};
|
|
14922
14886
|
}
|
|
14923
14887
|
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
|
|
14930
|
-
var pane = 'order-' + options.order;
|
|
14931
|
-
var exist = map.getPane(pane);
|
|
14932
|
-
if (!exist) {
|
|
14933
|
-
exist = map.createPane(pane);
|
|
14934
|
-
}
|
|
14935
|
-
exist.style.zIndex = String(Math.round(options.order * 100));
|
|
14936
|
-
this.pane = pane;
|
|
14937
|
-
}
|
|
14938
|
-
}
|
|
14939
|
-
BaseAdapter.prototype.addLayer = function (options) {
|
|
14940
|
-
Object.assign(this.options, options);
|
|
14941
|
-
return undefined;
|
|
14942
|
-
};
|
|
14943
|
-
return BaseAdapter;
|
|
14944
|
-
}());
|
|
14945
|
-
|
|
14946
|
-
var GeoJsonAdapter = /** @class */ (function (_super) {
|
|
14947
|
-
__extends(GeoJsonAdapter, _super);
|
|
14948
|
-
function GeoJsonAdapter(map, options) {
|
|
14949
|
-
var _this = _super.call(this, map, options) || this;
|
|
14950
|
-
_this.selected = false;
|
|
14951
|
-
_this._layers = [];
|
|
14952
|
-
_this._selectedLayers = [];
|
|
14953
|
-
_this._filteredLayers = [];
|
|
14954
|
-
_this._openedPopup = [];
|
|
14955
|
-
_this.$updateTooltip = debounce(function () {
|
|
14956
|
-
_this.updateTooltip();
|
|
14957
|
-
}, 300);
|
|
14958
|
-
_this.$unselect = function () {
|
|
14959
|
-
_this.unselect();
|
|
14960
|
-
};
|
|
14961
|
-
return _this;
|
|
14962
|
-
}
|
|
14963
|
-
GeoJsonAdapter.prototype.addLayer = function (options) {
|
|
14964
|
-
Object.assign(this.options, options);
|
|
14965
|
-
this.paint = options.paint;
|
|
14966
|
-
this.layer = new leafletSrc.exports.FeatureGroup([], __assign(__assign({}, options.nativeOptions), { pane: this.pane }));
|
|
14967
|
-
this.selectedPaint = options.selectedPaint;
|
|
14968
|
-
options.paint = this.paint;
|
|
14969
|
-
if (options.data) {
|
|
14970
|
-
this.addData(options.data);
|
|
14971
|
-
}
|
|
14972
|
-
this._addMapListener();
|
|
14973
|
-
return this.layer;
|
|
14974
|
-
};
|
|
14975
|
-
GeoJsonAdapter.prototype.beforeRemove = function () {
|
|
14976
|
-
this._removeMapListener();
|
|
14977
|
-
};
|
|
14978
|
-
GeoJsonAdapter.prototype.select = function (findFeatureFun) {
|
|
14979
|
-
this.unselect();
|
|
14980
|
-
if (findFeatureFun) {
|
|
14981
|
-
var def = this._layers.filter(findFeatureFun);
|
|
14982
|
-
for (var _i = 0, def_1 = def; _i < def_1.length; _i++) {
|
|
14983
|
-
var x = def_1[_i];
|
|
14984
|
-
this._selectLayer(x, 'api');
|
|
14985
|
-
}
|
|
14986
|
-
}
|
|
14987
|
-
else if (!this.selected) {
|
|
14988
|
-
this.selected = true;
|
|
14989
|
-
if (this.selectedPaint) {
|
|
14990
|
-
this._setPaintEachLayer(this.selectedPaint);
|
|
14991
|
-
}
|
|
14992
|
-
}
|
|
14993
|
-
};
|
|
14994
|
-
GeoJsonAdapter.prototype.unselect = function (findFeatureFun) {
|
|
14995
|
-
var _this = this;
|
|
14996
|
-
if (findFeatureFun) {
|
|
14997
|
-
var feature = this._layers.filter(findFeatureFun);
|
|
14998
|
-
feature.forEach(function (x) {
|
|
14999
|
-
_this._unSelectLayer(x);
|
|
15000
|
-
});
|
|
15001
|
-
}
|
|
15002
|
-
else if (this.selected) {
|
|
15003
|
-
for (var _i = 0, _a = this._openedPopup; _i < _a.length; _i++) {
|
|
15004
|
-
var p = _a[_i];
|
|
15005
|
-
this._removePopup(p[0]);
|
|
15006
|
-
}
|
|
15007
|
-
if (this.paint) {
|
|
15008
|
-
this._setPaintEachLayer(this.paint);
|
|
15009
|
-
}
|
|
15010
|
-
this._selectedLayers.length = 0;
|
|
15011
|
-
this.selected = false;
|
|
15012
|
-
}
|
|
15013
|
-
};
|
|
15014
|
-
GeoJsonAdapter.prototype.getSelected = function () {
|
|
15015
|
-
var _this = this;
|
|
15016
|
-
return this._selectedLayers.map(function (x) {
|
|
15017
|
-
return __assign({ target: _this, feature: x.feature, layer: x }, createFeaturePositionOptions(x.feature));
|
|
15018
|
-
});
|
|
15019
|
-
};
|
|
15020
|
-
GeoJsonAdapter.prototype.getFiltered = function () {
|
|
15021
|
-
return this._filteredLayers;
|
|
15022
|
-
};
|
|
15023
|
-
GeoJsonAdapter.prototype.filter = function (fun) {
|
|
15024
|
-
var _this = this;
|
|
15025
|
-
// Some optimization
|
|
15026
|
-
this._filterFun = fun;
|
|
15027
|
-
var layer_ = this.layer;
|
|
15028
|
-
var map = layer_ && layer_._map;
|
|
15029
|
-
if (layer_ && map) {
|
|
15030
|
-
layer_.remove();
|
|
15031
|
-
var filteredLayers_1 = [];
|
|
15032
|
-
this._layers.forEach(function (_a) {
|
|
15033
|
-
var feature = _a.feature, layer = _a.layer;
|
|
15034
|
-
if (layer) {
|
|
15035
|
-
var ok = fun
|
|
15036
|
-
? fun(__assign({ target: _this, feature: feature, layer: layer }, createFeaturePositionOptions(feature)))
|
|
15037
|
-
: true;
|
|
15038
|
-
if (ok) {
|
|
15039
|
-
layer_.addLayer(layer);
|
|
15040
|
-
filteredLayers_1.push(__assign({ target: _this, feature: feature, layer: layer }, createFeaturePositionOptions(feature)));
|
|
15041
|
-
}
|
|
15042
|
-
else {
|
|
15043
|
-
layer_.removeLayer(layer);
|
|
15044
|
-
}
|
|
15045
|
-
}
|
|
15046
|
-
});
|
|
15047
|
-
this._filteredLayers = filteredLayers_1;
|
|
15048
|
-
layer_.addTo(map);
|
|
15049
|
-
}
|
|
15050
|
-
return this._filteredLayers;
|
|
15051
|
-
};
|
|
15052
|
-
GeoJsonAdapter.prototype.cleanFilter = function () {
|
|
15053
|
-
this.filter();
|
|
15054
|
-
};
|
|
15055
|
-
GeoJsonAdapter.prototype.getLayers = function () {
|
|
15056
|
-
var _this = this;
|
|
15057
|
-
return this._layers.map(function (_a) {
|
|
15058
|
-
var layer = _a.layer, feature = _a.feature;
|
|
15059
|
-
var visible = layer && !!layer._map;
|
|
15060
|
-
return __assign({ feature: feature, layer: layer, visible: visible, target: _this }, createFeaturePositionOptions(feature));
|
|
15061
|
-
});
|
|
15062
|
-
};
|
|
15063
|
-
GeoJsonAdapter.prototype.clearLayer = function (cb) {
|
|
15064
|
-
this.unselect();
|
|
15065
|
-
var layer_ = this.layer;
|
|
15066
|
-
if (layer_) {
|
|
15067
|
-
if (cb) {
|
|
15068
|
-
for (var fry = this._layers.length; fry--;) {
|
|
15069
|
-
var def = this._layers[fry];
|
|
15070
|
-
if (def) {
|
|
15071
|
-
var feature = def.feature, layer = def.layer;
|
|
15072
|
-
if (feature && layer) {
|
|
15073
|
-
var exist = cb(feature);
|
|
15074
|
-
if (exist) {
|
|
15075
|
-
layer_.removeLayer(layer);
|
|
15076
|
-
this._layers.splice(fry, 1);
|
|
15077
|
-
}
|
|
15078
|
-
}
|
|
15079
|
-
}
|
|
15080
|
-
}
|
|
15081
|
-
}
|
|
15082
|
-
else {
|
|
15083
|
-
layer_.clearLayers();
|
|
15084
|
-
this._layers = [];
|
|
15085
|
-
}
|
|
15086
|
-
}
|
|
15087
|
-
};
|
|
15088
|
-
GeoJsonAdapter.prototype.setData = function (data) {
|
|
15089
|
-
this.clearLayer();
|
|
15090
|
-
this.addData(data);
|
|
15091
|
-
};
|
|
15092
|
-
GeoJsonAdapter.prototype.addData = function (data) {
|
|
15093
|
-
var options = this.options;
|
|
15094
|
-
var geoJsonOptions;
|
|
15095
|
-
if (options) {
|
|
15096
|
-
if (data) {
|
|
15097
|
-
var type = void 0;
|
|
15098
|
-
if (!options.type) {
|
|
15099
|
-
var detectedType = detectType(data);
|
|
15100
|
-
type = typeAlias[detectedType];
|
|
15101
|
-
}
|
|
15102
|
-
else {
|
|
15103
|
-
type = options.type;
|
|
15104
|
-
}
|
|
15105
|
-
if (this.type && this.type !== type) {
|
|
15106
|
-
console.warn('no other data type than layer can be added');
|
|
15107
|
-
return;
|
|
15108
|
-
}
|
|
15109
|
-
this.type = type;
|
|
15110
|
-
data = filterGeometries(data, type);
|
|
15111
|
-
if (data) {
|
|
15112
|
-
geoJsonOptions = this._getGeoJsonOptions(options, type);
|
|
15113
|
-
}
|
|
15114
|
-
}
|
|
15115
|
-
new leafletSrc.exports.GeoJSON(data || undefined, geoJsonOptions);
|
|
15116
|
-
}
|
|
15117
|
-
};
|
|
15118
|
-
GeoJsonAdapter.prototype.openPopup = function (findFeatureFun, options) {
|
|
15119
|
-
var _this = this;
|
|
15120
|
-
if (findFeatureFun) {
|
|
15121
|
-
var def = this._layers.filter(findFeatureFun);
|
|
15122
|
-
def.forEach(function (x) {
|
|
15123
|
-
_this._openPopup(x, options, 'api');
|
|
15124
|
-
});
|
|
15125
|
-
}
|
|
15126
|
-
};
|
|
15127
|
-
GeoJsonAdapter.prototype.closePopup = function (findFeatureFun) {
|
|
15128
|
-
var _this = this;
|
|
15129
|
-
var popupToClose = findFeatureFun
|
|
15130
|
-
? this._openedPopup.filter(function (x) { return findFeatureFun(x[2]); })
|
|
15131
|
-
: this._openedPopup;
|
|
15132
|
-
popupToClose.forEach(function (x) {
|
|
15133
|
-
_this._removePopup(x[0]);
|
|
15134
|
-
});
|
|
15135
|
-
};
|
|
15136
|
-
GeoJsonAdapter.prototype.updateTooltip = function (layerDef) {
|
|
15137
|
-
var _this = this;
|
|
15138
|
-
if (layerDef) {
|
|
15139
|
-
this._updateTooltip(layerDef);
|
|
15140
|
-
}
|
|
15141
|
-
else {
|
|
15142
|
-
this.getLayers().forEach(function (x) {
|
|
15143
|
-
return _this._updateTooltip({ feature: x.feature, layer: x.layer });
|
|
15144
|
-
});
|
|
15145
|
-
}
|
|
15146
|
-
};
|
|
15147
|
-
/** @deprecated use {@link GeoJsonAdapter.getBounds} instead */
|
|
15148
|
-
GeoJsonAdapter.prototype.getExtent = function () {
|
|
15149
|
-
return this.getBounds();
|
|
15150
|
-
};
|
|
15151
|
-
GeoJsonAdapter.prototype.getBounds = function () {
|
|
15152
|
-
if (this.layer) {
|
|
15153
|
-
var bounds = this.layer.getBounds();
|
|
15154
|
-
if (bounds.isValid()) {
|
|
15155
|
-
return boundsToArray(bounds);
|
|
15156
|
-
}
|
|
15157
|
-
}
|
|
15158
|
-
};
|
|
15159
|
-
GeoJsonAdapter.prototype.setOpacity = function (value) {
|
|
15160
|
-
this.options.opacity = value;
|
|
15161
|
-
this.setPaint(this.paint);
|
|
15162
|
-
this.setSelectedPaint(this.selectedPaint);
|
|
15163
|
-
};
|
|
15164
|
-
GeoJsonAdapter.prototype.setPaint = function (paint) {
|
|
15165
|
-
if (paint) {
|
|
15166
|
-
this.paint = paint;
|
|
15167
|
-
for (var _i = 0, _a = this._layers; _i < _a.length; _i++) {
|
|
15168
|
-
var l = _a[_i];
|
|
15169
|
-
this._setPaint(l, paint);
|
|
15170
|
-
}
|
|
15171
|
-
}
|
|
15172
|
-
};
|
|
15173
|
-
GeoJsonAdapter.prototype.setSelectedPaint = function (paint) {
|
|
15174
|
-
if (paint) {
|
|
15175
|
-
this.selectedPaint = paint;
|
|
15176
|
-
for (var _i = 0, _a = this._selectedLayers; _i < _a.length; _i++) {
|
|
15177
|
-
var l = _a[_i];
|
|
15178
|
-
this._setPaint(l, paint);
|
|
15179
|
-
}
|
|
15180
|
-
}
|
|
15181
|
-
};
|
|
15182
|
-
GeoJsonAdapter.prototype.updatePaint = function (paint) {
|
|
15183
|
-
this.paint = __assign(__assign({}, this.paint), paint);
|
|
15184
|
-
for (var _i = 0, _a = this._layers; _i < _a.length; _i++) {
|
|
15185
|
-
var l = _a[_i];
|
|
15186
|
-
this._setPaint(l, this.paint);
|
|
15187
|
-
}
|
|
15188
|
-
};
|
|
15189
|
-
GeoJsonAdapter.prototype.updateSelectedPaint = function (paint) {
|
|
15190
|
-
this.selectedPaint = __assign(__assign({}, this.selectedPaint), paint);
|
|
15191
|
-
for (var _i = 0, _a = this._selectedLayers; _i < _a.length; _i++) {
|
|
15192
|
-
var l = _a[_i];
|
|
15193
|
-
this._setPaint(l, this.selectedPaint);
|
|
15194
|
-
}
|
|
15195
|
-
};
|
|
15196
|
-
GeoJsonAdapter.prototype._updateTooltip = function (layerDef) {
|
|
15197
|
-
var feature = layerDef.feature, layer = layerDef.layer;
|
|
15198
|
-
if (feature && layer && feature.properties && this.options.labelField) {
|
|
15199
|
-
layer.unbindTooltip();
|
|
15200
|
-
var message = feature.properties[this.options.labelField];
|
|
15201
|
-
if (message !== undefined) {
|
|
15202
|
-
var permanent = !this.options.labelOnHover;
|
|
15203
|
-
layer.bindTooltip(String(message), { permanent: permanent, sticky: false });
|
|
15204
|
-
}
|
|
15205
|
-
}
|
|
15206
|
-
};
|
|
15207
|
-
GeoJsonAdapter.prototype._openPopup = function (def, options, type, latLng) {
|
|
15208
|
-
var _a, _b;
|
|
15209
|
-
if (options === void 0) { options = {}; }
|
|
15210
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15211
|
-
var feature, layer, _c, minWidth, autoPan, maxWidth, closeButton_, closeButton, popup, _closeHandlers, onClose, close, content, popupOptions, unselectOnClose, p;
|
|
15212
|
-
var _this = this;
|
|
15213
|
-
return __generator(this, function (_d) {
|
|
15214
|
-
switch (_d.label) {
|
|
15215
|
-
case 0:
|
|
15216
|
-
feature = def.feature, layer = def.layer;
|
|
15217
|
-
_c = __assign({ minWidth: 300 }, options), minWidth = _c.minWidth, autoPan = _c.autoPan, maxWidth = _c.maxWidth, closeButton_ = _c.closeButton;
|
|
15218
|
-
closeButton = closeButton_ !== null && closeButton_ !== void 0 ? closeButton_ : !this.options.selectOnHover;
|
|
15219
|
-
_closeHandlers = [];
|
|
15220
|
-
onClose = function (handler) {
|
|
15221
|
-
_closeHandlers.push(handler);
|
|
15222
|
-
};
|
|
15223
|
-
close = function () {
|
|
15224
|
-
if (popup) {
|
|
15225
|
-
_this._removePopup(popup);
|
|
15226
|
-
}
|
|
15227
|
-
};
|
|
15228
|
-
if (!options.createPopupContent) return [3 /*break*/, 2];
|
|
15229
|
-
return [4 /*yield*/, options.createPopupContent(__assign({ layer: layer, feature: feature, target: this, type: type, close: close, onClose: onClose }, createFeaturePositionOptions(feature)))];
|
|
15230
|
-
case 1:
|
|
15231
|
-
content = _d.sent();
|
|
15232
|
-
return [3 /*break*/, 3];
|
|
15233
|
-
case 2:
|
|
15234
|
-
content = options.popupContent;
|
|
15235
|
-
_d.label = 3;
|
|
15236
|
-
case 3:
|
|
15237
|
-
if (content && layer) {
|
|
15238
|
-
popupOptions = {
|
|
15239
|
-
minWidth: minWidth,
|
|
15240
|
-
autoPan: autoPan,
|
|
15241
|
-
// maxWidth,
|
|
15242
|
-
closeButton: closeButton,
|
|
15243
|
-
closeOnClick: false,
|
|
15244
|
-
autoClose: false,
|
|
15245
|
-
};
|
|
15246
|
-
if (defined(maxWidth)) {
|
|
15247
|
-
popupOptions.maxWidth = maxWidth;
|
|
15248
|
-
}
|
|
15249
|
-
popup = layer.bindPopup(content, popupOptions);
|
|
15250
|
-
unselectOnClose = (_b = (_a = this.options.popupOptions) === null || _a === void 0 ? void 0 : _a.unselectOnClose) !== null && _b !== void 0 ? _b : true;
|
|
15251
|
-
if (unselectOnClose) {
|
|
15252
|
-
p = layer.getPopup();
|
|
15253
|
-
p &&
|
|
15254
|
-
p.once('remove', function () {
|
|
15255
|
-
close();
|
|
15256
|
-
}, this);
|
|
15257
|
-
}
|
|
15258
|
-
this._openedPopup.push([popup, _closeHandlers, def]);
|
|
15259
|
-
popup.openPopup(latLng);
|
|
15260
|
-
}
|
|
15261
|
-
return [2 /*return*/];
|
|
15262
|
-
}
|
|
15263
|
-
});
|
|
15264
|
-
});
|
|
15265
|
-
};
|
|
15266
|
-
GeoJsonAdapter.prototype._removePopup = function (popup) {
|
|
15267
|
-
var _a, _b;
|
|
15268
|
-
var map = this.map;
|
|
15269
|
-
if (map) {
|
|
15270
|
-
popup.closePopup().unbindPopup();
|
|
15271
|
-
var index = this._openedPopup.findIndex(function (x) { return x[0] === popup; });
|
|
15272
|
-
if (index !== -1) {
|
|
15273
|
-
var unselectOnClose = (_b = (_a = this.options.popupOptions) === null || _a === void 0 ? void 0 : _a.unselectOnClose) !== null && _b !== void 0 ? _b : true;
|
|
15274
|
-
var _c = this._openedPopup[index], closeHandlers = _c[1], def = _c[2];
|
|
15275
|
-
for (var _i = 0, closeHandlers_1 = closeHandlers; _i < closeHandlers_1.length; _i++) {
|
|
15276
|
-
var h = closeHandlers_1[_i];
|
|
15277
|
-
h(def);
|
|
15278
|
-
}
|
|
15279
|
-
closeHandlers.length = 0;
|
|
15280
|
-
if (unselectOnClose) {
|
|
15281
|
-
this._unSelectLayer(def);
|
|
15282
|
-
}
|
|
15283
|
-
this._openedPopup.splice(index, 1);
|
|
15284
|
-
}
|
|
15285
|
-
}
|
|
15286
|
-
};
|
|
15287
|
-
GeoJsonAdapter.prototype._setPaintEachLayer = function (paint) {
|
|
15288
|
-
var _this = this;
|
|
15289
|
-
this._layers.forEach(function (l) {
|
|
15290
|
-
_this._setPaint(l, paint);
|
|
15291
|
-
});
|
|
15292
|
-
};
|
|
15293
|
-
GeoJsonAdapter.prototype._setPaint = function (def, paint) {
|
|
15294
|
-
var style = undefined;
|
|
15295
|
-
var layer = def.layer, feature = def.feature;
|
|
15296
|
-
if (layer && feature) {
|
|
15297
|
-
if (isPaintCallback(paint)) {
|
|
15298
|
-
style = paint(feature);
|
|
15299
|
-
}
|
|
15300
|
-
else if (isPaint(paint)) {
|
|
15301
|
-
style = paint;
|
|
15302
|
-
}
|
|
15303
|
-
if (style) {
|
|
15304
|
-
if (this.type === 'point' && style.type === 'icon') {
|
|
15305
|
-
var marker = layer;
|
|
15306
|
-
var divIcon = this._createDivIcon(style);
|
|
15307
|
-
marker.setIcon(divIcon);
|
|
15308
|
-
}
|
|
15309
|
-
else if ('setStyle' in layer) {
|
|
15310
|
-
layer.setStyle(this._preparePaint(style));
|
|
15311
|
-
}
|
|
15312
|
-
}
|
|
15313
|
-
}
|
|
15314
|
-
};
|
|
15315
|
-
GeoJsonAdapter.prototype._preparePaint = function (paint) {
|
|
15316
|
-
if (paint.type !== 'get-paint') {
|
|
15317
|
-
// const path: CircleMarkerOptions | PathOptions = paint as CircleMarkerOptions | PathOptions;
|
|
15318
|
-
// if (path.opacity) {
|
|
15319
|
-
// path.fillOpacity = path.opacity;
|
|
15320
|
-
// }
|
|
15321
|
-
var paintAliases = [
|
|
15322
|
-
// ['color', 'color'],
|
|
15323
|
-
['color', 'strokeColor'],
|
|
15324
|
-
['opacity', 'strokeOpacity'],
|
|
15325
|
-
['stroke', 'stroke'],
|
|
15326
|
-
['fillColor', 'fillColor'],
|
|
15327
|
-
['fillOpacity', 'fillOpacity'],
|
|
15328
|
-
['fill', 'fill'],
|
|
15329
|
-
['weight', 'weight'],
|
|
15330
|
-
];
|
|
15331
|
-
var aliases = this.type === 'line'
|
|
15332
|
-
? [
|
|
15333
|
-
['color', 'strokeColor'],
|
|
15334
|
-
['opacity', 'strokeOpacity'],
|
|
15335
|
-
['weight', 'weight'],
|
|
15336
|
-
]
|
|
15337
|
-
: paintAliases;
|
|
15338
|
-
var readyPaint = {};
|
|
15339
|
-
if ('radius' in paint && typeof paint.radius === 'number') {
|
|
15340
|
-
readyPaint.radius = paint.radius;
|
|
15341
|
-
}
|
|
15342
|
-
for (var _i = 0, aliases_1 = aliases; _i < aliases_1.length; _i++) {
|
|
15343
|
-
var _a = aliases_1[_i], to = _a[0], from = _a[1];
|
|
15344
|
-
var paintProp = paint[from];
|
|
15345
|
-
if (defined(this.options.opacity) &&
|
|
15346
|
-
from.toLowerCase().indexOf('opacity') !== -1) {
|
|
15347
|
-
paintProp = Number(paintProp) * this.options.opacity;
|
|
15348
|
-
}
|
|
15349
|
-
if (paintProp !== undefined) {
|
|
15350
|
-
Object.defineProperty(readyPaint, to, {
|
|
15351
|
-
enumerable: true,
|
|
15352
|
-
value: paintProp,
|
|
15353
|
-
});
|
|
15354
|
-
}
|
|
15355
|
-
}
|
|
15356
|
-
return readyPaint;
|
|
15357
|
-
}
|
|
15358
|
-
return PAINT;
|
|
15359
|
-
};
|
|
15360
|
-
GeoJsonAdapter.prototype._getGeoJsonOptions = function (options, type) {
|
|
15361
|
-
var _this = this;
|
|
15362
|
-
var paint = options.paint;
|
|
15363
|
-
var lopt = {};
|
|
15364
|
-
if (typeof paint === 'function') {
|
|
15365
|
-
if (type === 'point') {
|
|
15366
|
-
// TODO: fix types (@geoman-io/leaflet-geoman-free)
|
|
15367
|
-
lopt.pointToLayer = function (feature, latLng) {
|
|
15368
|
-
var iconOpt = paint(feature);
|
|
15369
|
-
var pointToLayer = _this._createPaintToLayer(iconOpt);
|
|
15370
|
-
return pointToLayer(feature, latLng);
|
|
15371
|
-
};
|
|
15372
|
-
}
|
|
15373
|
-
else {
|
|
15374
|
-
lopt = {
|
|
15375
|
-
style: function (feature) {
|
|
15376
|
-
if (feature) {
|
|
15377
|
-
return _this._preparePaint(__assign(__assign({}, PAINT), paint(feature)));
|
|
15378
|
-
}
|
|
15379
|
-
else {
|
|
15380
|
-
return _this._preparePaint(__assign(__assign({}, PAINT), { type: 'path' }));
|
|
15381
|
-
}
|
|
15382
|
-
},
|
|
15383
|
-
};
|
|
15384
|
-
}
|
|
15385
|
-
}
|
|
15386
|
-
else {
|
|
15387
|
-
lopt = this._createPaintOptions(paint, type);
|
|
15388
|
-
}
|
|
15389
|
-
lopt.onEachFeature = function (feature, layer) {
|
|
15390
|
-
_this._onEachFeature(feature, layer);
|
|
15391
|
-
};
|
|
15392
|
-
return lopt;
|
|
15393
|
-
};
|
|
15394
|
-
GeoJsonAdapter.prototype._onEachFeature = function (feature, layer) {
|
|
15395
|
-
var _this = this;
|
|
15396
|
-
var layer_ = this.layer;
|
|
15397
|
-
if (layer_) {
|
|
15398
|
-
var def_2 = __assign({ target: this, feature: feature, layer: layer }, createFeaturePositionOptions(feature));
|
|
15399
|
-
// @ts-ignore
|
|
15400
|
-
layer.options.pane = this.pane;
|
|
15401
|
-
this._layers.push(def_2);
|
|
15402
|
-
var ok = true;
|
|
15403
|
-
if (this._filterFun) {
|
|
15404
|
-
ok = this._filterFun(def_2);
|
|
15405
|
-
}
|
|
15406
|
-
if (ok) {
|
|
15407
|
-
var _a = this.options, popup_1 = _a.popup, popupOptions_1 = _a.popupOptions, selectable = _a.selectable, interactive = _a.interactive, selectOnHover = _a.selectOnHover;
|
|
15408
|
-
// @ts-ignore
|
|
15409
|
-
layer.options.interactive = defined(interactive) ? interactive : true;
|
|
15410
|
-
layer_.addLayer(layer);
|
|
15411
|
-
if (selectable) {
|
|
15412
|
-
if (selectOnHover) {
|
|
15413
|
-
layer.on('mouseover', function () {
|
|
15414
|
-
_this._selectLayer(def_2, 'hover');
|
|
15415
|
-
});
|
|
15416
|
-
layer.on('mouseout', function () {
|
|
15417
|
-
_this._unSelectLayer(def_2);
|
|
15418
|
-
});
|
|
15419
|
-
}
|
|
15420
|
-
else {
|
|
15421
|
-
layer.on('click', function (e) { return _this._selectOnLayerClick(e); }, this);
|
|
15422
|
-
}
|
|
15423
|
-
}
|
|
15424
|
-
this._handleMouseEvents(layer);
|
|
15425
|
-
// The timeout is needed to display the popup immediately when adding a layer to the map.
|
|
15426
|
-
// Without a timeout, the layer may not yet have a _map object
|
|
15427
|
-
setTimeout(function () {
|
|
15428
|
-
if (popup_1) {
|
|
15429
|
-
_this._openPopup(__assign({ target: _this, layer: layer, feature: feature }, createFeaturePositionOptions(feature)), popupOptions_1, 'api');
|
|
15430
|
-
}
|
|
15431
|
-
_this._updateTooltip({ layer: layer, feature: feature });
|
|
15432
|
-
});
|
|
15433
|
-
}
|
|
15434
|
-
}
|
|
15435
|
-
};
|
|
15436
|
-
GeoJsonAdapter.prototype._handleMouseEvents = function (layer) {
|
|
15437
|
-
var _this = this;
|
|
15438
|
-
var _a = this.options, onClick = _a.onClick, onLayerClick = _a.onLayerClick, onMouseOut = _a.onMouseOut, onMouseOver = _a.onMouseOver;
|
|
15439
|
-
// TODO: remove backward compatibility for onLayerClick
|
|
15440
|
-
var onClick_ = onClick || onLayerClick;
|
|
15441
|
-
if (onClick_) {
|
|
15442
|
-
layer.on('click', function (e) {
|
|
15443
|
-
var selected = !!_this._getSelected(layer);
|
|
15444
|
-
onClick_(__assign({ selected: selected }, _this._createMouseEvent(e)));
|
|
15445
|
-
}, this);
|
|
15446
|
-
}
|
|
15447
|
-
if (onMouseOut) {
|
|
15448
|
-
layer.on('mouseout', function (e) {
|
|
15449
|
-
onMouseOut(_this._createMouseEvent(e));
|
|
15450
|
-
}, this);
|
|
15451
|
-
}
|
|
15452
|
-
if (onMouseOver) {
|
|
15453
|
-
layer.on('mouseover', function (e) {
|
|
15454
|
-
onMouseOver(_this._createMouseEvent(e));
|
|
15455
|
-
}, this);
|
|
15456
|
-
}
|
|
15457
|
-
};
|
|
15458
|
-
GeoJsonAdapter.prototype._createMouseEvent = function (source) {
|
|
15459
|
-
return createMouseEvent({
|
|
15460
|
-
layer: this,
|
|
15461
|
-
source: source,
|
|
15462
|
-
});
|
|
15463
|
-
};
|
|
15464
|
-
GeoJsonAdapter.prototype._getSelected = function (layer) {
|
|
15465
|
-
return this._selectedLayers.find(function (x) { return x.layer === layer; });
|
|
15466
|
-
};
|
|
15467
|
-
GeoJsonAdapter.prototype._selectOnLayerClick = function (e) {
|
|
15468
|
-
leafletSrc.exports.DomEvent.stopPropagation(e);
|
|
15469
|
-
var layer = e.target;
|
|
15470
|
-
var feature = layer.feature;
|
|
15471
|
-
var def = __assign({ target: this, layer: layer, feature: feature }, createFeaturePositionOptions(feature));
|
|
15472
|
-
var isSelected = this._getSelected(layer);
|
|
15473
|
-
if (isSelected) {
|
|
15474
|
-
if (this.options && this.options.unselectOnSecondClick) {
|
|
15475
|
-
this._unSelectLayer(isSelected);
|
|
15476
|
-
}
|
|
15477
|
-
}
|
|
15478
|
-
else {
|
|
15479
|
-
this._selectLayer(def, 'click', e.latlng);
|
|
15480
|
-
}
|
|
15481
|
-
};
|
|
15482
|
-
GeoJsonAdapter.prototype._selectLayer = function (def, type, latlng) {
|
|
15483
|
-
var _this = this;
|
|
15484
|
-
var multiselect = this.options.multiselect;
|
|
15485
|
-
if (!multiselect) {
|
|
15486
|
-
// To unselect layer on another layer click
|
|
15487
|
-
this.map._addUnselectCb(function () {
|
|
15488
|
-
_this._unSelectLayer(def);
|
|
15489
|
-
});
|
|
15490
|
-
this._selectedLayers.forEach(function (x) { return _this._unSelectLayer(x); });
|
|
15491
|
-
}
|
|
15492
|
-
this._selectedLayers.push(def);
|
|
15493
|
-
this.selected = true;
|
|
15494
|
-
var _a = this.options, selectedPaint = _a.selectedPaint, popupOnSelect = _a.popupOnSelect, popupOptions = _a.popupOptions;
|
|
15495
|
-
if (selectedPaint && def.layer) {
|
|
15496
|
-
this._setPaint(def, selectedPaint);
|
|
15497
|
-
}
|
|
15498
|
-
if (popupOnSelect) {
|
|
15499
|
-
this._openPopup(def, popupOptions, type, latlng);
|
|
15500
|
-
}
|
|
15501
|
-
if (this.options.onSelect) {
|
|
15502
|
-
var features = def.feature ? [def.feature] : [];
|
|
15503
|
-
this.options.onSelect(__assign({ type: type, layer: this, features: features }, createFeaturePositionOptions(features)));
|
|
15504
|
-
}
|
|
15505
|
-
};
|
|
15506
|
-
GeoJsonAdapter.prototype._unSelectLayer = function (def) {
|
|
15507
|
-
var index = this._selectedLayers.indexOf(def);
|
|
15508
|
-
if (index !== -1) {
|
|
15509
|
-
this._selectedLayers.splice(index, 1);
|
|
15510
|
-
if (this.options) {
|
|
15511
|
-
if (this.options.paint) {
|
|
15512
|
-
this._setPaint(def, this.options.paint);
|
|
15513
|
-
}
|
|
15514
|
-
if (this.options.popupOnSelect && def.layer) {
|
|
15515
|
-
this._removePopup(def.layer);
|
|
15516
|
-
}
|
|
15517
|
-
}
|
|
15518
|
-
}
|
|
15519
|
-
this.selected = this._selectedLayers.length > 0;
|
|
15520
|
-
};
|
|
15521
|
-
GeoJsonAdapter.prototype._createDivIcon = function (icon) {
|
|
15522
|
-
var toLIconOpt = __rest(icon, []);
|
|
15523
|
-
return new leafletSrc.exports.DivIcon(__assign({ className: '' }, toLIconOpt));
|
|
15524
|
-
};
|
|
15525
|
-
GeoJsonAdapter.prototype._createPaintToLayer = function (icon) {
|
|
15526
|
-
var _this = this;
|
|
15527
|
-
if (icon && icon.type) {
|
|
15528
|
-
if (icon.type === 'icon') {
|
|
15529
|
-
var iconClassName = icon.className;
|
|
15530
|
-
var html = icon.html;
|
|
15531
|
-
if (iconClassName || html) {
|
|
15532
|
-
return function (geoJsonPoint, latlng) {
|
|
15533
|
-
var divIcon = _this._createDivIcon(icon);
|
|
15534
|
-
return new leafletSrc.exports.Marker(latlng, { icon: divIcon });
|
|
15535
|
-
};
|
|
15536
|
-
}
|
|
15537
|
-
}
|
|
15538
|
-
else if (icon.type === 'pin') {
|
|
15539
|
-
return function (geoJsonPoint, latlng) {
|
|
15540
|
-
// const divIcon = this.createDivIcon(icon);
|
|
15541
|
-
return new leafletSrc.exports.Marker(latlng);
|
|
15542
|
-
};
|
|
15543
|
-
}
|
|
15544
|
-
}
|
|
15545
|
-
return function (geoJsonPoint, latlng) {
|
|
15546
|
-
var p = PAINT;
|
|
15547
|
-
return new leafletSrc.exports.CircleMarker(latlng, _this._preparePaint(__assign(__assign({}, p), icon)));
|
|
15548
|
-
};
|
|
15549
|
-
};
|
|
15550
|
-
GeoJsonAdapter.prototype._createPaintOptions = function (paintOptions, type) {
|
|
15551
|
-
var geoJsonOptions = {};
|
|
15552
|
-
var paint = (paintOptions && this._preparePaint(paintOptions)) || {};
|
|
15553
|
-
if (paintOptions) {
|
|
15554
|
-
geoJsonOptions.style = function () {
|
|
15555
|
-
return paint;
|
|
15556
|
-
};
|
|
15557
|
-
}
|
|
15558
|
-
if (type === 'point') {
|
|
15559
|
-
geoJsonOptions.pointToLayer = this._createPaintToLayer(paintOptions);
|
|
15560
|
-
}
|
|
15561
|
-
else if (type === 'line') {
|
|
15562
|
-
paint.stroke = true;
|
|
15563
|
-
}
|
|
15564
|
-
return geoJsonOptions;
|
|
15565
|
-
};
|
|
15566
|
-
GeoJsonAdapter.prototype._addMapClickListener = function () {
|
|
15567
|
-
var map = this.map;
|
|
15568
|
-
if (map) {
|
|
15569
|
-
var unselectOnClick = this.options.unselectOnClick;
|
|
15570
|
-
var uoc = unselectOnClick !== null && unselectOnClick !== void 0 ? unselectOnClick : true;
|
|
15571
|
-
if (uoc) {
|
|
15572
|
-
map.on('click', this.$unselect);
|
|
15573
|
-
}
|
|
15574
|
-
}
|
|
15575
|
-
};
|
|
15576
|
-
GeoJsonAdapter.prototype._removeMapClickListener = function () {
|
|
15577
|
-
this.map.off('zoomend', this.$updateTooltip);
|
|
15578
|
-
this.map.off('moveend', this.$updateTooltip);
|
|
15579
|
-
this.map.off('click', this.$unselect);
|
|
15580
|
-
};
|
|
15581
|
-
GeoJsonAdapter.prototype._addMapListener = function () {
|
|
15582
|
-
var map = this.map;
|
|
15583
|
-
if (map) {
|
|
15584
|
-
var _a = this.options, labelField = _a.labelField, labelOnHover = _a.labelOnHover;
|
|
15585
|
-
this._addMapClickListener();
|
|
15586
|
-
if (labelField && !labelOnHover) {
|
|
15587
|
-
map.on('zoomend', this.$updateTooltip);
|
|
15588
|
-
map.on('moveend', this.$updateTooltip);
|
|
15589
|
-
}
|
|
15590
|
-
}
|
|
15591
|
-
};
|
|
15592
|
-
GeoJsonAdapter.prototype._removeMapListener = function () {
|
|
15593
|
-
this._removeMapClickListener();
|
|
15594
|
-
this.map.off('zoomend', this.$updateTooltip);
|
|
15595
|
-
this.map.off('moveend', this.$updateTooltip);
|
|
15596
|
-
};
|
|
15597
|
-
return GeoJsonAdapter;
|
|
15598
|
-
}(BaseAdapter));
|
|
15599
|
-
|
|
15600
|
-
function callAjax(src, callback, headers) {
|
|
15601
|
-
var xhr = new XMLHttpRequest();
|
|
15602
|
-
xhr.open('GET', src);
|
|
15603
|
-
xhr.responseType = 'arraybuffer';
|
|
15604
|
-
for (var h in headers) {
|
|
15605
|
-
xhr.setRequestHeader(h, headers[h]);
|
|
15606
|
-
}
|
|
15607
|
-
xhr.onload = function () {
|
|
15608
|
-
var arrayBufferView = new Uint8Array(this.response);
|
|
15609
|
-
var blob = new Blob([arrayBufferView], { type: 'image/png' });
|
|
15610
|
-
// @ts-ignore for typedoc
|
|
15611
|
-
var urlCreator = window.URL || window.webkitURL;
|
|
15612
|
-
var imageUrl = urlCreator.createObjectURL(blob);
|
|
15613
|
-
callback(imageUrl);
|
|
15614
|
-
};
|
|
15615
|
-
xhr.send();
|
|
15616
|
-
return function () {
|
|
15617
|
-
xhr.abort();
|
|
15618
|
-
};
|
|
14888
|
+
function createMouseEvent(_a) {
|
|
14889
|
+
var layer = _a.layer, source = _a.source;
|
|
14890
|
+
var layer_ = source.target;
|
|
14891
|
+
var feature = layer_.feature;
|
|
14892
|
+
var opt = __assign({ layer: layer, feature: feature, event: convertMapClickEvent(source), source: source }, createFeaturePositionOptions(feature));
|
|
14893
|
+
return opt;
|
|
15619
14894
|
}
|
|
15620
14895
|
|
|
15621
|
-
|
|
15622
|
-
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
|
|
15626
|
-
|
|
15627
|
-
|
|
15628
|
-
|
|
15629
|
-
if (
|
|
15630
|
-
|
|
15631
|
-
|
|
15632
|
-
|
|
15633
|
-
|
|
15634
|
-
|
|
15635
|
-
|
|
15636
|
-
|
|
15637
|
-
|
|
15638
|
-
var
|
|
15639
|
-
|
|
15640
|
-
|
|
15641
|
-
|
|
15642
|
-
|
|
15643
|
-
|
|
15644
|
-
|
|
15645
|
-
|
|
15646
|
-
|
|
15647
|
-
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
|
|
14896
|
+
function findMostFrequentGeomType(arr) {
|
|
14897
|
+
var counts = {};
|
|
14898
|
+
for (var fry = 0; fry < arr.length; fry++) {
|
|
14899
|
+
counts[arr[fry]] = 1 + (counts[arr[fry]] || 0);
|
|
14900
|
+
}
|
|
14901
|
+
var maxName = '';
|
|
14902
|
+
for (var c in counts) {
|
|
14903
|
+
var maxCount = maxName ? counts[maxName] : 0;
|
|
14904
|
+
if (counts[c] > maxCount) {
|
|
14905
|
+
maxName = c;
|
|
14906
|
+
}
|
|
14907
|
+
}
|
|
14908
|
+
return maxName;
|
|
14909
|
+
}
|
|
14910
|
+
function detectType(geojson) {
|
|
14911
|
+
var geometry;
|
|
14912
|
+
if (geojson.type === 'FeatureCollection') {
|
|
14913
|
+
var featuresTypes = geojson.features.map(function (f) { return f.geometry.type; });
|
|
14914
|
+
geometry = findMostFrequentGeomType(featuresTypes);
|
|
14915
|
+
}
|
|
14916
|
+
else if (geojson.type === 'GeometryCollection') {
|
|
14917
|
+
var geometryTypes = geojson.geometries.map(function (g) { return g.type; });
|
|
14918
|
+
geometry = findMostFrequentGeomType(geometryTypes);
|
|
14919
|
+
}
|
|
14920
|
+
else if (geojson.type === 'Feature') {
|
|
14921
|
+
geometry = geojson.geometry.type;
|
|
14922
|
+
}
|
|
14923
|
+
else {
|
|
14924
|
+
geometry = geojson.type;
|
|
14925
|
+
}
|
|
14926
|
+
return geometry;
|
|
14927
|
+
}
|
|
15651
14928
|
|
|
15652
|
-
|
|
15653
|
-
|
|
15654
|
-
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
|
|
15661
|
-
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
|
|
15669
|
-
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
styles: '',
|
|
15674
|
-
format: 'image/jpeg',
|
|
15675
|
-
transparent: false,
|
|
15676
|
-
};
|
|
15677
|
-
_this.options = {
|
|
15678
|
-
crs: null,
|
|
15679
|
-
uppercase: false,
|
|
15680
|
-
attribution: '',
|
|
15681
|
-
opacity: 1,
|
|
15682
|
-
isBack: false,
|
|
15683
|
-
minZoom: 0,
|
|
15684
|
-
pane: 'tilePane',
|
|
15685
|
-
headers: null,
|
|
15686
|
-
viewPortBuffer: 0,
|
|
15687
|
-
setViewDelay: 100,
|
|
15688
|
-
};
|
|
15689
|
-
_this._url = url;
|
|
15690
|
-
// Move WMS parameters to params object
|
|
15691
|
-
var params = {};
|
|
15692
|
-
var opts = {};
|
|
15693
|
-
var opt;
|
|
15694
|
-
for (opt in options) {
|
|
15695
|
-
if (opt in _this.options) {
|
|
15696
|
-
opts[opt] = options[opt];
|
|
15697
|
-
}
|
|
15698
|
-
else {
|
|
15699
|
-
params[opt] = options[opt];
|
|
15700
|
-
}
|
|
15701
|
-
}
|
|
15702
|
-
leafletSrc.exports.Util.setOptions(_this, opts);
|
|
15703
|
-
_this.wmsParams = leafletSrc.exports.Util.extend({}, _this.defaultWmsParams, params);
|
|
15704
|
-
return _this;
|
|
15705
|
-
}
|
|
15706
|
-
ImageLayer.prototype.setParams = function (params) {
|
|
15707
|
-
leafletSrc.exports.Util.extend(this.wmsParams, params);
|
|
15708
|
-
this.update();
|
|
15709
|
-
};
|
|
15710
|
-
ImageLayer.prototype.getAttribution = function () {
|
|
15711
|
-
return this.options.attribution || '';
|
|
15712
|
-
};
|
|
15713
|
-
ImageLayer.prototype.onAdd = function () {
|
|
15714
|
-
this.update();
|
|
15715
|
-
return this;
|
|
15716
|
-
};
|
|
15717
|
-
ImageLayer.prototype.onRemove = function (map) {
|
|
15718
|
-
if (this._currentOverlay) {
|
|
15719
|
-
this._currentOverlay.cancelLoad();
|
|
15720
|
-
map.removeLayer(this._currentOverlay);
|
|
15721
|
-
delete this._currentOverlay;
|
|
15722
|
-
}
|
|
15723
|
-
if (this._currentUrl) {
|
|
15724
|
-
delete this._currentUrl;
|
|
15725
|
-
}
|
|
15726
|
-
return this;
|
|
15727
|
-
};
|
|
15728
|
-
ImageLayer.prototype.getEvents = function () {
|
|
15729
|
-
return {
|
|
15730
|
-
moveend: debounce(this.update, this.options.setViewDelay),
|
|
15731
|
-
};
|
|
15732
|
-
};
|
|
15733
|
-
ImageLayer.prototype.update = function () {
|
|
15734
|
-
var _this = this;
|
|
15735
|
-
if (!this._map) {
|
|
15736
|
-
return;
|
|
15737
|
-
}
|
|
15738
|
-
// Determine image URL and whether it has changed since last update
|
|
15739
|
-
this.updateWmsParams();
|
|
15740
|
-
var url = this.getImageUrl();
|
|
15741
|
-
if (this._currentUrl === url) {
|
|
15742
|
-
return;
|
|
15743
|
-
}
|
|
15744
|
-
this._currentUrl = url;
|
|
15745
|
-
// Keep current image overlay in place until new one loads
|
|
15746
|
-
// (inspired by esri.leaflet)
|
|
15747
|
-
var viewPortBuffer = this.options.viewPortBuffer || 0;
|
|
15748
|
-
var bounds = this._map.getBounds().pad(viewPortBuffer);
|
|
15749
|
-
var overlay = new ImageOverlay(url, bounds, {
|
|
15750
|
-
opacity: 0,
|
|
15751
|
-
pane: this.options.pane,
|
|
15752
|
-
headers: this.options.headers,
|
|
15753
|
-
});
|
|
15754
|
-
overlay.addTo(this._map);
|
|
15755
|
-
if (this._currentOverlay) {
|
|
15756
|
-
this._currentOverlay.cancelLoad();
|
|
15757
|
-
}
|
|
15758
|
-
overlay.once('load', function () {
|
|
15759
|
-
if (!_this._map) {
|
|
15760
|
-
return;
|
|
15761
|
-
}
|
|
15762
|
-
// @ts-ignore
|
|
15763
|
-
if (overlay._url !== _this._currentUrl) {
|
|
15764
|
-
_this._map.removeLayer(overlay);
|
|
15765
|
-
return;
|
|
15766
|
-
}
|
|
15767
|
-
else if (_this._currentOverlay) {
|
|
15768
|
-
_this._map.removeLayer(_this._currentOverlay);
|
|
15769
|
-
}
|
|
15770
|
-
_this._currentOverlay = overlay;
|
|
15771
|
-
overlay.setOpacity(_this.options.opacity !== undefined ? _this.options.opacity : 1);
|
|
15772
|
-
if (_this.options.isBack === true) {
|
|
15773
|
-
overlay.bringToBack();
|
|
15774
|
-
}
|
|
15775
|
-
if (_this.options.isBack === false) {
|
|
15776
|
-
overlay.bringToFront();
|
|
15777
|
-
}
|
|
15778
|
-
if (_this.options.zIndex !== undefined) {
|
|
15779
|
-
overlay.setZIndex(_this.options.zIndex);
|
|
15780
|
-
}
|
|
15781
|
-
}, this);
|
|
15782
|
-
var _a = this.options, minZoom = _a.minZoom, maxZoom = _a.maxZoom;
|
|
15783
|
-
if ((minZoom && this._map.getZoom() < minZoom) ||
|
|
15784
|
-
(maxZoom && this._map.getZoom() > maxZoom)) {
|
|
15785
|
-
this._map.removeLayer(overlay);
|
|
15786
|
-
}
|
|
15787
|
-
};
|
|
15788
|
-
ImageLayer.prototype.setOpacity = function (opacity) {
|
|
15789
|
-
this.options.opacity = opacity;
|
|
15790
|
-
if (this._currentOverlay) {
|
|
15791
|
-
this._currentOverlay.setOpacity(opacity);
|
|
15792
|
-
}
|
|
15793
|
-
};
|
|
15794
|
-
ImageLayer.prototype.bringToBack = function () {
|
|
15795
|
-
this.options.isBack = true;
|
|
15796
|
-
if (this._currentOverlay) {
|
|
15797
|
-
this._currentOverlay.bringToBack();
|
|
15798
|
-
}
|
|
15799
|
-
};
|
|
15800
|
-
ImageLayer.prototype.bringToFront = function () {
|
|
15801
|
-
this.options.isBack = false;
|
|
15802
|
-
if (this._currentOverlay) {
|
|
15803
|
-
this._currentOverlay.bringToFront();
|
|
15804
|
-
}
|
|
15805
|
-
};
|
|
15806
|
-
ImageLayer.prototype.setZIndex = function (zIndex) {
|
|
15807
|
-
this.options.zIndex = zIndex;
|
|
15808
|
-
if (this._currentOverlay) {
|
|
15809
|
-
this._currentOverlay.setZIndex(zIndex);
|
|
15810
|
-
}
|
|
15811
|
-
};
|
|
15812
|
-
// See L.TileLayer.WMS: onAdd() & getTileUrl()
|
|
15813
|
-
ImageLayer.prototype.updateWmsParams = function (map) {
|
|
15814
|
-
if (!map) {
|
|
15815
|
-
map = this._map;
|
|
15816
|
-
}
|
|
15817
|
-
// Compute WMS options
|
|
15818
|
-
var viewPortBuffer = this.options.viewPortBuffer || 0;
|
|
15819
|
-
var bounds = map.getBounds().pad(viewPortBuffer);
|
|
15820
|
-
var size = map.getSize();
|
|
15821
|
-
if (this.options.viewPortBuffer !== 0) {
|
|
15822
|
-
var factor = viewPortBuffer + 1;
|
|
15823
|
-
size.x = Math.ceil(size.x * factor);
|
|
15824
|
-
size.y = Math.ceil(size.y * factor);
|
|
15825
|
-
}
|
|
15826
|
-
var wmsVersion = parseFloat(this.wmsParams.version);
|
|
15827
|
-
var crs = this.options.crs || map.options.crs;
|
|
15828
|
-
var projectionKey = wmsVersion >= 1.3 ? 'crs' : 'srs';
|
|
15829
|
-
if (crs) {
|
|
15830
|
-
var nw = crs.project(bounds.getNorthWest());
|
|
15831
|
-
var se = crs.project(bounds.getSouthEast());
|
|
15832
|
-
// Assemble WMS parameter string
|
|
15833
|
-
var params = {
|
|
15834
|
-
width: size.x,
|
|
15835
|
-
height: size.y,
|
|
15836
|
-
};
|
|
15837
|
-
params[projectionKey] = crs.code;
|
|
15838
|
-
params.bbox = (wmsVersion >= 1.3 && crs === leafletSrc.exports.CRS.EPSG4326
|
|
15839
|
-
? [se.y, nw.x, nw.y, se.x]
|
|
15840
|
-
: [nw.x, se.y, se.x, nw.y]).join(',');
|
|
15841
|
-
leafletSrc.exports.Util.extend(this.wmsParams, params);
|
|
15842
|
-
}
|
|
15843
|
-
};
|
|
15844
|
-
ImageLayer.prototype.getImageUrl = function () {
|
|
15845
|
-
var uppercase = this.options.uppercase || false;
|
|
15846
|
-
var pstr = leafletSrc.exports.Util.getParamString(this.wmsParams, this._url, uppercase);
|
|
15847
|
-
return this._url + pstr;
|
|
15848
|
-
};
|
|
15849
|
-
return ImageLayer;
|
|
15850
|
-
}(leafletSrc.exports.Layer));
|
|
14929
|
+
var BaseAdapter = /** @class */ (function () {
|
|
14930
|
+
function BaseAdapter(map, options) {
|
|
14931
|
+
this.map = map;
|
|
14932
|
+
this.options = options;
|
|
14933
|
+
this.pane = 'order-0';
|
|
14934
|
+
if (options.order !== undefined) {
|
|
14935
|
+
var pane = 'order-' + options.order;
|
|
14936
|
+
var exist = map.getPane(pane);
|
|
14937
|
+
if (!exist) {
|
|
14938
|
+
exist = map.createPane(pane);
|
|
14939
|
+
}
|
|
14940
|
+
exist.style.zIndex = String(Math.round(options.order * 100));
|
|
14941
|
+
this.pane = pane;
|
|
14942
|
+
}
|
|
14943
|
+
}
|
|
14944
|
+
BaseAdapter.prototype.addLayer = function (options) {
|
|
14945
|
+
Object.assign(this.options, options);
|
|
14946
|
+
return undefined;
|
|
14947
|
+
};
|
|
14948
|
+
return BaseAdapter;
|
|
14949
|
+
}());
|
|
15851
14950
|
|
|
15852
|
-
var
|
|
15853
|
-
__extends(
|
|
15854
|
-
function
|
|
15855
|
-
|
|
15856
|
-
|
|
15857
|
-
|
|
15858
|
-
|
|
15859
|
-
|
|
15860
|
-
|
|
15861
|
-
|
|
15862
|
-
|
|
15863
|
-
|
|
15864
|
-
|
|
15865
|
-
|
|
15866
|
-
|
|
15867
|
-
|
|
15868
|
-
|
|
15869
|
-
|
|
15870
|
-
|
|
15871
|
-
|
|
15872
|
-
|
|
15873
|
-
|
|
14951
|
+
var GeoJsonAdapter = /** @class */ (function (_super) {
|
|
14952
|
+
__extends(GeoJsonAdapter, _super);
|
|
14953
|
+
function GeoJsonAdapter(map, options) {
|
|
14954
|
+
var _this = _super.call(this, map, options) || this;
|
|
14955
|
+
_this.selected = false;
|
|
14956
|
+
_this._layers = [];
|
|
14957
|
+
_this._selectedLayers = [];
|
|
14958
|
+
_this._filteredLayers = [];
|
|
14959
|
+
_this._openedPopup = [];
|
|
14960
|
+
_this.$updateTooltip = debounce(function () {
|
|
14961
|
+
_this.updateTooltip();
|
|
14962
|
+
}, 300);
|
|
14963
|
+
_this.$unselect = function () {
|
|
14964
|
+
_this.unselect();
|
|
14965
|
+
};
|
|
14966
|
+
return _this;
|
|
14967
|
+
}
|
|
14968
|
+
GeoJsonAdapter.prototype.addLayer = function (options) {
|
|
14969
|
+
Object.assign(this.options, options);
|
|
14970
|
+
this.paint = options.paint;
|
|
14971
|
+
this.layer = new leafletSrc.exports.FeatureGroup([], __assign(__assign({}, options.nativeOptions), { pane: this.pane }));
|
|
14972
|
+
this.selectedPaint = options.selectedPaint;
|
|
14973
|
+
options.paint = this.paint;
|
|
14974
|
+
if (options.data) {
|
|
14975
|
+
this.addData(options.data);
|
|
14976
|
+
}
|
|
14977
|
+
this._addMapListener();
|
|
14978
|
+
return this.layer;
|
|
14979
|
+
};
|
|
14980
|
+
GeoJsonAdapter.prototype.beforeRemove = function () {
|
|
14981
|
+
this._removeMapListener();
|
|
14982
|
+
};
|
|
14983
|
+
GeoJsonAdapter.prototype.select = function (findFeatureFun) {
|
|
14984
|
+
this.unselect();
|
|
14985
|
+
if (findFeatureFun) {
|
|
14986
|
+
var def = this._layers.filter(findFeatureFun);
|
|
14987
|
+
for (var _i = 0, def_1 = def; _i < def_1.length; _i++) {
|
|
14988
|
+
var x = def_1[_i];
|
|
14989
|
+
this._selectLayer(x, 'api');
|
|
14990
|
+
}
|
|
14991
|
+
}
|
|
14992
|
+
else if (!this.selected) {
|
|
14993
|
+
this.selected = true;
|
|
14994
|
+
if (this.selectedPaint) {
|
|
14995
|
+
this._setPaintEachLayer(this.selectedPaint);
|
|
14996
|
+
}
|
|
14997
|
+
}
|
|
14998
|
+
};
|
|
14999
|
+
GeoJsonAdapter.prototype.unselect = function (findFeatureFun) {
|
|
15000
|
+
var _this = this;
|
|
15001
|
+
if (findFeatureFun) {
|
|
15002
|
+
var feature = this._layers.filter(findFeatureFun);
|
|
15003
|
+
feature.forEach(function (x) {
|
|
15004
|
+
_this._unSelectLayer(x);
|
|
15005
|
+
});
|
|
15006
|
+
}
|
|
15007
|
+
else if (this.selected) {
|
|
15008
|
+
for (var _i = 0, _a = this._openedPopup; _i < _a.length; _i++) {
|
|
15009
|
+
var p = _a[_i];
|
|
15010
|
+
this._removePopup(p[0]);
|
|
15011
|
+
}
|
|
15012
|
+
if (this.paint) {
|
|
15013
|
+
this._setPaintEachLayer(this.paint);
|
|
15014
|
+
}
|
|
15015
|
+
this._selectedLayers.length = 0;
|
|
15016
|
+
this.selected = false;
|
|
15017
|
+
}
|
|
15018
|
+
};
|
|
15019
|
+
GeoJsonAdapter.prototype.getSelected = function () {
|
|
15020
|
+
var _this = this;
|
|
15021
|
+
return this._selectedLayers.map(function (x) {
|
|
15022
|
+
return __assign({ target: _this, feature: x.feature, layer: x }, createFeaturePositionOptions(x.feature));
|
|
15023
|
+
});
|
|
15024
|
+
};
|
|
15025
|
+
GeoJsonAdapter.prototype.getFiltered = function () {
|
|
15026
|
+
return this._filteredLayers;
|
|
15027
|
+
};
|
|
15028
|
+
GeoJsonAdapter.prototype.filter = function (fun) {
|
|
15029
|
+
var _this = this;
|
|
15030
|
+
// Some optimization
|
|
15031
|
+
this._filterFun = fun;
|
|
15032
|
+
var layer_ = this.layer;
|
|
15033
|
+
var map = layer_ && layer_._map;
|
|
15034
|
+
if (layer_ && map) {
|
|
15035
|
+
layer_.remove();
|
|
15036
|
+
var filteredLayers_1 = [];
|
|
15037
|
+
this._layers.forEach(function (_a) {
|
|
15038
|
+
var feature = _a.feature, layer = _a.layer;
|
|
15039
|
+
if (layer) {
|
|
15040
|
+
var ok = fun
|
|
15041
|
+
? fun(__assign({ target: _this, feature: feature, layer: layer }, createFeaturePositionOptions(feature)))
|
|
15042
|
+
: true;
|
|
15043
|
+
if (ok) {
|
|
15044
|
+
layer_.addLayer(layer);
|
|
15045
|
+
filteredLayers_1.push(__assign({ target: _this, feature: feature, layer: layer }, createFeaturePositionOptions(feature)));
|
|
15046
|
+
}
|
|
15047
|
+
else {
|
|
15048
|
+
layer_.removeLayer(layer);
|
|
15049
|
+
}
|
|
15050
|
+
}
|
|
15051
|
+
});
|
|
15052
|
+
this._filteredLayers = filteredLayers_1;
|
|
15053
|
+
layer_.addTo(map);
|
|
15054
|
+
}
|
|
15055
|
+
return this._filteredLayers;
|
|
15056
|
+
};
|
|
15057
|
+
GeoJsonAdapter.prototype.cleanFilter = function () {
|
|
15058
|
+
this.filter();
|
|
15059
|
+
};
|
|
15060
|
+
GeoJsonAdapter.prototype.getLayers = function () {
|
|
15061
|
+
var _this = this;
|
|
15062
|
+
return this._layers.map(function (_a) {
|
|
15063
|
+
var layer = _a.layer, feature = _a.feature;
|
|
15064
|
+
var visible = layer && !!layer._map;
|
|
15065
|
+
return __assign({ feature: feature, layer: layer, visible: visible, target: _this }, createFeaturePositionOptions(feature));
|
|
15066
|
+
});
|
|
15067
|
+
};
|
|
15068
|
+
GeoJsonAdapter.prototype.clearLayer = function (cb) {
|
|
15069
|
+
this.unselect();
|
|
15070
|
+
var layer_ = this.layer;
|
|
15071
|
+
if (layer_) {
|
|
15072
|
+
if (cb) {
|
|
15073
|
+
for (var fry = this._layers.length; fry--;) {
|
|
15074
|
+
var def = this._layers[fry];
|
|
15075
|
+
if (def) {
|
|
15076
|
+
var feature = def.feature, layer = def.layer;
|
|
15077
|
+
if (feature && layer) {
|
|
15078
|
+
var exist = cb(feature);
|
|
15079
|
+
if (exist) {
|
|
15080
|
+
layer_.removeLayer(layer);
|
|
15081
|
+
this._layers.splice(fry, 1);
|
|
15082
|
+
}
|
|
15083
|
+
}
|
|
15084
|
+
}
|
|
15085
|
+
}
|
|
15086
|
+
}
|
|
15087
|
+
else {
|
|
15088
|
+
layer_.clearLayers();
|
|
15089
|
+
this._layers = [];
|
|
15090
|
+
}
|
|
15091
|
+
}
|
|
15092
|
+
};
|
|
15093
|
+
GeoJsonAdapter.prototype.setData = function (data) {
|
|
15094
|
+
this.clearLayer();
|
|
15095
|
+
this.addData(data);
|
|
15096
|
+
};
|
|
15097
|
+
GeoJsonAdapter.prototype.addData = function (data) {
|
|
15098
|
+
var options = this.options;
|
|
15099
|
+
var geoJsonOptions;
|
|
15100
|
+
if (options) {
|
|
15101
|
+
if (data) {
|
|
15102
|
+
var type = void 0;
|
|
15103
|
+
if (!options.type) {
|
|
15104
|
+
var detectedType = detectType(data);
|
|
15105
|
+
type = typeAlias[detectedType];
|
|
15106
|
+
}
|
|
15107
|
+
else {
|
|
15108
|
+
type = options.type;
|
|
15109
|
+
}
|
|
15110
|
+
if (this.type && this.type !== type) {
|
|
15111
|
+
console.warn('no other data type than layer can be added');
|
|
15112
|
+
return;
|
|
15113
|
+
}
|
|
15114
|
+
this.type = type;
|
|
15115
|
+
data = filterGeometries(data, type);
|
|
15116
|
+
if (data) {
|
|
15117
|
+
geoJsonOptions = this._getGeoJsonOptions(options, type);
|
|
15118
|
+
}
|
|
15119
|
+
}
|
|
15120
|
+
new leafletSrc.exports.GeoJSON(data || undefined, geoJsonOptions);
|
|
15121
|
+
}
|
|
15122
|
+
};
|
|
15123
|
+
GeoJsonAdapter.prototype.openPopup = function (findFeatureFun, options) {
|
|
15124
|
+
var _this = this;
|
|
15125
|
+
if (findFeatureFun) {
|
|
15126
|
+
var def = this._layers.filter(findFeatureFun);
|
|
15127
|
+
def.forEach(function (x) {
|
|
15128
|
+
_this._openPopup(x, options, 'api');
|
|
15129
|
+
});
|
|
15130
|
+
}
|
|
15131
|
+
};
|
|
15132
|
+
GeoJsonAdapter.prototype.closePopup = function (findFeatureFun) {
|
|
15133
|
+
var _this = this;
|
|
15134
|
+
var popupToClose = findFeatureFun
|
|
15135
|
+
? this._openedPopup.filter(function (x) { return findFeatureFun(x[2]); })
|
|
15136
|
+
: this._openedPopup;
|
|
15137
|
+
popupToClose.forEach(function (x) {
|
|
15138
|
+
_this._removePopup(x[0]);
|
|
15139
|
+
});
|
|
15140
|
+
};
|
|
15141
|
+
GeoJsonAdapter.prototype.updateTooltip = function (layerDef) {
|
|
15142
|
+
var _this = this;
|
|
15143
|
+
if (layerDef) {
|
|
15144
|
+
this._updateTooltip(layerDef);
|
|
15145
|
+
}
|
|
15146
|
+
else {
|
|
15147
|
+
this.getLayers().forEach(function (x) {
|
|
15148
|
+
return _this._updateTooltip({ feature: x.feature, layer: x.layer });
|
|
15149
|
+
});
|
|
15150
|
+
}
|
|
15151
|
+
};
|
|
15152
|
+
/** @deprecated use {@link GeoJsonAdapter.getBounds} instead */
|
|
15153
|
+
GeoJsonAdapter.prototype.getExtent = function () {
|
|
15154
|
+
return this.getBounds();
|
|
15155
|
+
};
|
|
15156
|
+
GeoJsonAdapter.prototype.getBounds = function () {
|
|
15157
|
+
if (this.layer) {
|
|
15158
|
+
var bounds = this.layer.getBounds();
|
|
15159
|
+
if (bounds.isValid()) {
|
|
15160
|
+
return boundsToArray(bounds);
|
|
15161
|
+
}
|
|
15162
|
+
}
|
|
15163
|
+
};
|
|
15164
|
+
GeoJsonAdapter.prototype.setOpacity = function (value) {
|
|
15165
|
+
this.options.opacity = value;
|
|
15166
|
+
this.setPaint(this.paint);
|
|
15167
|
+
this.setSelectedPaint(this.selectedPaint);
|
|
15168
|
+
};
|
|
15169
|
+
GeoJsonAdapter.prototype.setPaint = function (paint) {
|
|
15170
|
+
if (paint) {
|
|
15171
|
+
this.paint = paint;
|
|
15172
|
+
for (var _i = 0, _a = this._layers; _i < _a.length; _i++) {
|
|
15173
|
+
var l = _a[_i];
|
|
15174
|
+
this._setPaint(l, paint);
|
|
15175
|
+
}
|
|
15176
|
+
}
|
|
15177
|
+
};
|
|
15178
|
+
GeoJsonAdapter.prototype.setSelectedPaint = function (paint) {
|
|
15179
|
+
if (paint) {
|
|
15180
|
+
this.selectedPaint = paint;
|
|
15181
|
+
for (var _i = 0, _a = this._selectedLayers; _i < _a.length; _i++) {
|
|
15182
|
+
var l = _a[_i];
|
|
15183
|
+
this._setPaint(l, paint);
|
|
15184
|
+
}
|
|
15185
|
+
}
|
|
15186
|
+
};
|
|
15187
|
+
GeoJsonAdapter.prototype.updatePaint = function (paint) {
|
|
15188
|
+
this.paint = __assign(__assign({}, this.paint), paint);
|
|
15189
|
+
for (var _i = 0, _a = this._layers; _i < _a.length; _i++) {
|
|
15190
|
+
var l = _a[_i];
|
|
15191
|
+
this._setPaint(l, this.paint);
|
|
15192
|
+
}
|
|
15193
|
+
};
|
|
15194
|
+
GeoJsonAdapter.prototype.updateSelectedPaint = function (paint) {
|
|
15195
|
+
this.selectedPaint = __assign(__assign({}, this.selectedPaint), paint);
|
|
15196
|
+
for (var _i = 0, _a = this._selectedLayers; _i < _a.length; _i++) {
|
|
15197
|
+
var l = _a[_i];
|
|
15198
|
+
this._setPaint(l, this.selectedPaint);
|
|
15199
|
+
}
|
|
15200
|
+
};
|
|
15201
|
+
GeoJsonAdapter.prototype._updateTooltip = function (layerDef) {
|
|
15202
|
+
var feature = layerDef.feature, layer = layerDef.layer;
|
|
15203
|
+
if (feature && layer && feature.properties && this.options.labelField) {
|
|
15204
|
+
layer.unbindTooltip();
|
|
15205
|
+
var message = feature.properties[this.options.labelField];
|
|
15206
|
+
if (message !== undefined) {
|
|
15207
|
+
var permanent = !this.options.labelOnHover;
|
|
15208
|
+
layer.bindTooltip(String(message), { permanent: permanent, sticky: false });
|
|
15209
|
+
}
|
|
15210
|
+
}
|
|
15211
|
+
};
|
|
15212
|
+
GeoJsonAdapter.prototype._openPopup = function (def, options, type, latLng) {
|
|
15213
|
+
var _a, _b;
|
|
15214
|
+
if (options === void 0) { options = {}; }
|
|
15215
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15216
|
+
var feature, layer, _c, minWidth, autoPan, maxWidth, closeButton_, closeButton, popup, _closeHandlers, onClose, close, content, popupOptions, unselectOnClose, p;
|
|
15217
|
+
var _this = this;
|
|
15218
|
+
return __generator(this, function (_d) {
|
|
15219
|
+
switch (_d.label) {
|
|
15220
|
+
case 0:
|
|
15221
|
+
feature = def.feature, layer = def.layer;
|
|
15222
|
+
_c = __assign({ minWidth: 300 }, options), minWidth = _c.minWidth, autoPan = _c.autoPan, maxWidth = _c.maxWidth, closeButton_ = _c.closeButton;
|
|
15223
|
+
closeButton = closeButton_ !== null && closeButton_ !== void 0 ? closeButton_ : !this.options.selectOnHover;
|
|
15224
|
+
_closeHandlers = [];
|
|
15225
|
+
onClose = function (handler) {
|
|
15226
|
+
_closeHandlers.push(handler);
|
|
15227
|
+
};
|
|
15228
|
+
close = function () {
|
|
15229
|
+
if (popup) {
|
|
15230
|
+
_this._removePopup(popup);
|
|
15231
|
+
}
|
|
15232
|
+
};
|
|
15233
|
+
if (!options.createPopupContent) return [3 /*break*/, 2];
|
|
15234
|
+
return [4 /*yield*/, options.createPopupContent(__assign({ layer: layer, feature: feature, target: this, type: type, close: close, onClose: onClose }, createFeaturePositionOptions(feature)))];
|
|
15235
|
+
case 1:
|
|
15236
|
+
content = _d.sent();
|
|
15237
|
+
return [3 /*break*/, 3];
|
|
15238
|
+
case 2:
|
|
15239
|
+
content = options.popupContent;
|
|
15240
|
+
_d.label = 3;
|
|
15241
|
+
case 3:
|
|
15242
|
+
if (content && layer) {
|
|
15243
|
+
popupOptions = {
|
|
15244
|
+
minWidth: minWidth,
|
|
15245
|
+
autoPan: autoPan,
|
|
15246
|
+
// maxWidth,
|
|
15247
|
+
closeButton: closeButton,
|
|
15248
|
+
closeOnClick: false,
|
|
15249
|
+
autoClose: false,
|
|
15250
|
+
};
|
|
15251
|
+
if (defined(maxWidth)) {
|
|
15252
|
+
popupOptions.maxWidth = maxWidth;
|
|
15253
|
+
}
|
|
15254
|
+
popup = layer.bindPopup(content, popupOptions);
|
|
15255
|
+
unselectOnClose = (_b = (_a = this.options.popupOptions) === null || _a === void 0 ? void 0 : _a.unselectOnClose) !== null && _b !== void 0 ? _b : true;
|
|
15256
|
+
if (unselectOnClose) {
|
|
15257
|
+
p = layer.getPopup();
|
|
15258
|
+
p &&
|
|
15259
|
+
p.once('remove', function () {
|
|
15260
|
+
close();
|
|
15261
|
+
}, this);
|
|
15262
|
+
}
|
|
15263
|
+
this._openedPopup.push([popup, _closeHandlers, def]);
|
|
15264
|
+
popup.openPopup(latLng);
|
|
15265
|
+
}
|
|
15266
|
+
return [2 /*return*/];
|
|
15267
|
+
}
|
|
15268
|
+
});
|
|
15269
|
+
});
|
|
15270
|
+
};
|
|
15271
|
+
GeoJsonAdapter.prototype._removePopup = function (popup) {
|
|
15272
|
+
var _a, _b;
|
|
15273
|
+
var map = this.map;
|
|
15274
|
+
if (map) {
|
|
15275
|
+
popup.closePopup().unbindPopup();
|
|
15276
|
+
var index = this._openedPopup.findIndex(function (x) { return x[0] === popup; });
|
|
15277
|
+
if (index !== -1) {
|
|
15278
|
+
var unselectOnClose = (_b = (_a = this.options.popupOptions) === null || _a === void 0 ? void 0 : _a.unselectOnClose) !== null && _b !== void 0 ? _b : true;
|
|
15279
|
+
var _c = this._openedPopup[index], closeHandlers = _c[1], def = _c[2];
|
|
15280
|
+
for (var _i = 0, closeHandlers_1 = closeHandlers; _i < closeHandlers_1.length; _i++) {
|
|
15281
|
+
var h = closeHandlers_1[_i];
|
|
15282
|
+
h(def);
|
|
15283
|
+
}
|
|
15284
|
+
closeHandlers.length = 0;
|
|
15285
|
+
if (unselectOnClose) {
|
|
15286
|
+
this._unSelectLayer(def);
|
|
15287
|
+
}
|
|
15288
|
+
this._openedPopup.splice(index, 1);
|
|
15289
|
+
}
|
|
15290
|
+
}
|
|
15291
|
+
};
|
|
15292
|
+
GeoJsonAdapter.prototype._setPaintEachLayer = function (paint) {
|
|
15293
|
+
var _this = this;
|
|
15294
|
+
this._layers.forEach(function (l) {
|
|
15295
|
+
_this._setPaint(l, paint);
|
|
15296
|
+
});
|
|
15297
|
+
};
|
|
15298
|
+
GeoJsonAdapter.prototype._setPaint = function (def, paint) {
|
|
15299
|
+
var style = undefined;
|
|
15300
|
+
var layer = def.layer, feature = def.feature;
|
|
15301
|
+
if (layer && feature) {
|
|
15302
|
+
if (isPaintCallback(paint)) {
|
|
15303
|
+
style = paint(feature);
|
|
15304
|
+
}
|
|
15305
|
+
else if (isPaint(paint)) {
|
|
15306
|
+
style = paint;
|
|
15307
|
+
}
|
|
15308
|
+
if (style) {
|
|
15309
|
+
if (this.type === 'point' && style.type === 'icon') {
|
|
15310
|
+
var marker = layer;
|
|
15311
|
+
var divIcon = this._createDivIcon(style);
|
|
15312
|
+
marker.setIcon(divIcon);
|
|
15313
|
+
}
|
|
15314
|
+
else if ('setStyle' in layer) {
|
|
15315
|
+
layer.setStyle(this._preparePaint(style));
|
|
15316
|
+
}
|
|
15317
|
+
}
|
|
15318
|
+
}
|
|
15319
|
+
};
|
|
15320
|
+
GeoJsonAdapter.prototype._preparePaint = function (paint) {
|
|
15321
|
+
if (paint.type !== 'get-paint') {
|
|
15322
|
+
// const path: CircleMarkerOptions | PathOptions = paint as CircleMarkerOptions | PathOptions;
|
|
15323
|
+
// if (path.opacity) {
|
|
15324
|
+
// path.fillOpacity = path.opacity;
|
|
15325
|
+
// }
|
|
15326
|
+
var paintAliases = [
|
|
15327
|
+
// ['color', 'color'],
|
|
15328
|
+
['color', 'strokeColor'],
|
|
15329
|
+
['opacity', 'strokeOpacity'],
|
|
15330
|
+
['stroke', 'stroke'],
|
|
15331
|
+
['fillColor', 'fillColor'],
|
|
15332
|
+
['fillOpacity', 'fillOpacity'],
|
|
15333
|
+
['fill', 'fill'],
|
|
15334
|
+
['weight', 'weight'],
|
|
15335
|
+
];
|
|
15336
|
+
var aliases = this.type === 'line'
|
|
15337
|
+
? [
|
|
15338
|
+
['color', 'strokeColor'],
|
|
15339
|
+
['opacity', 'strokeOpacity'],
|
|
15340
|
+
['weight', 'weight'],
|
|
15341
|
+
]
|
|
15342
|
+
: paintAliases;
|
|
15343
|
+
var readyPaint = {};
|
|
15344
|
+
if ('radius' in paint && typeof paint.radius === 'number') {
|
|
15345
|
+
readyPaint.radius = paint.radius;
|
|
15346
|
+
}
|
|
15347
|
+
for (var _i = 0, aliases_1 = aliases; _i < aliases_1.length; _i++) {
|
|
15348
|
+
var _a = aliases_1[_i], to = _a[0], from = _a[1];
|
|
15349
|
+
var paintProp = paint[from];
|
|
15350
|
+
if (defined(this.options.opacity) &&
|
|
15351
|
+
from.toLowerCase().indexOf('opacity') !== -1) {
|
|
15352
|
+
paintProp = Number(paintProp) * this.options.opacity;
|
|
15353
|
+
}
|
|
15354
|
+
if (paintProp !== undefined) {
|
|
15355
|
+
Object.defineProperty(readyPaint, to, {
|
|
15356
|
+
enumerable: true,
|
|
15357
|
+
value: paintProp,
|
|
15358
|
+
});
|
|
15359
|
+
}
|
|
15360
|
+
}
|
|
15361
|
+
return readyPaint;
|
|
15362
|
+
}
|
|
15363
|
+
return PAINT;
|
|
15364
|
+
};
|
|
15365
|
+
GeoJsonAdapter.prototype._getGeoJsonOptions = function (options, type) {
|
|
15366
|
+
var _this = this;
|
|
15367
|
+
var paint = options.paint;
|
|
15368
|
+
var lopt = {};
|
|
15369
|
+
if (typeof paint === 'function') {
|
|
15370
|
+
if (type === 'point') {
|
|
15371
|
+
// TODO: fix types (@geoman-io/leaflet-geoman-free)
|
|
15372
|
+
lopt.pointToLayer = function (feature, latLng) {
|
|
15373
|
+
var iconOpt = paint(feature);
|
|
15374
|
+
var pointToLayer = _this._createPaintToLayer(iconOpt);
|
|
15375
|
+
return pointToLayer(feature, latLng);
|
|
15376
|
+
};
|
|
15377
|
+
}
|
|
15378
|
+
else {
|
|
15379
|
+
lopt = {
|
|
15380
|
+
style: function (feature) {
|
|
15381
|
+
if (feature) {
|
|
15382
|
+
return _this._preparePaint(__assign(__assign({}, PAINT), paint(feature)));
|
|
15383
|
+
}
|
|
15384
|
+
else {
|
|
15385
|
+
return _this._preparePaint(__assign(__assign({}, PAINT), { type: 'path' }));
|
|
15386
|
+
}
|
|
15387
|
+
},
|
|
15388
|
+
};
|
|
15389
|
+
}
|
|
15390
|
+
}
|
|
15391
|
+
else {
|
|
15392
|
+
lopt = this._createPaintOptions(paint, type);
|
|
15393
|
+
}
|
|
15394
|
+
lopt.onEachFeature = function (feature, layer) {
|
|
15395
|
+
_this._onEachFeature(feature, layer);
|
|
15396
|
+
};
|
|
15397
|
+
return lopt;
|
|
15398
|
+
};
|
|
15399
|
+
GeoJsonAdapter.prototype._onEachFeature = function (feature, layer) {
|
|
15400
|
+
var _this = this;
|
|
15401
|
+
var layer_ = this.layer;
|
|
15402
|
+
if (layer_) {
|
|
15403
|
+
var def_2 = __assign({ target: this, feature: feature, layer: layer }, createFeaturePositionOptions(feature));
|
|
15404
|
+
// @ts-ignore
|
|
15405
|
+
layer.options.pane = this.pane;
|
|
15406
|
+
this._layers.push(def_2);
|
|
15407
|
+
var ok = true;
|
|
15408
|
+
if (this._filterFun) {
|
|
15409
|
+
ok = this._filterFun(def_2);
|
|
15410
|
+
}
|
|
15411
|
+
if (ok) {
|
|
15412
|
+
var _a = this.options, popup_1 = _a.popup, popupOptions_1 = _a.popupOptions, selectable = _a.selectable, interactive = _a.interactive, selectOnHover = _a.selectOnHover;
|
|
15413
|
+
// @ts-ignore
|
|
15414
|
+
layer.options.interactive = defined(interactive) ? interactive : true;
|
|
15415
|
+
layer_.addLayer(layer);
|
|
15416
|
+
if (selectable) {
|
|
15417
|
+
if (selectOnHover) {
|
|
15418
|
+
layer.on('mouseover', function () {
|
|
15419
|
+
_this._selectLayer(def_2, 'hover');
|
|
15420
|
+
});
|
|
15421
|
+
layer.on('mouseout', function () {
|
|
15422
|
+
_this._unSelectLayer(def_2);
|
|
15423
|
+
});
|
|
15424
|
+
}
|
|
15425
|
+
else {
|
|
15426
|
+
layer.on('click', function (e) { return _this._selectOnLayerClick(e); }, this);
|
|
15427
|
+
}
|
|
15428
|
+
}
|
|
15429
|
+
this._handleMouseEvents(layer);
|
|
15430
|
+
// The timeout is needed to display the popup immediately when adding a layer to the map.
|
|
15431
|
+
// Without a timeout, the layer may not yet have a _map object
|
|
15432
|
+
setTimeout(function () {
|
|
15433
|
+
if (popup_1) {
|
|
15434
|
+
_this._openPopup(__assign({ target: _this, layer: layer, feature: feature }, createFeaturePositionOptions(feature)), popupOptions_1, 'api');
|
|
15435
|
+
}
|
|
15436
|
+
_this._updateTooltip({ layer: layer, feature: feature });
|
|
15437
|
+
});
|
|
15438
|
+
}
|
|
15439
|
+
}
|
|
15440
|
+
};
|
|
15441
|
+
GeoJsonAdapter.prototype._handleMouseEvents = function (layer) {
|
|
15442
|
+
var _this = this;
|
|
15443
|
+
var _a = this.options, onClick = _a.onClick, onLayerClick = _a.onLayerClick, onMouseOut = _a.onMouseOut, onMouseOver = _a.onMouseOver;
|
|
15444
|
+
// TODO: remove backward compatibility for onLayerClick
|
|
15445
|
+
var onClick_ = onClick || onLayerClick;
|
|
15446
|
+
if (onClick_) {
|
|
15447
|
+
layer.on('click', function (e) {
|
|
15448
|
+
var selected = !!_this._getSelected(layer);
|
|
15449
|
+
onClick_(__assign({ selected: selected }, _this._createMouseEvent(e)));
|
|
15450
|
+
}, this);
|
|
15451
|
+
}
|
|
15452
|
+
if (onMouseOut) {
|
|
15453
|
+
layer.on('mouseout', function (e) {
|
|
15454
|
+
onMouseOut(_this._createMouseEvent(e));
|
|
15455
|
+
}, this);
|
|
15456
|
+
}
|
|
15457
|
+
if (onMouseOver) {
|
|
15458
|
+
layer.on('mouseover', function (e) {
|
|
15459
|
+
onMouseOver(_this._createMouseEvent(e));
|
|
15460
|
+
}, this);
|
|
15461
|
+
}
|
|
15462
|
+
};
|
|
15463
|
+
GeoJsonAdapter.prototype._createMouseEvent = function (source) {
|
|
15464
|
+
return createMouseEvent({
|
|
15465
|
+
layer: this,
|
|
15466
|
+
source: source,
|
|
15467
|
+
});
|
|
15468
|
+
};
|
|
15469
|
+
GeoJsonAdapter.prototype._getSelected = function (layer) {
|
|
15470
|
+
return this._selectedLayers.find(function (x) { return x.layer === layer; });
|
|
15471
|
+
};
|
|
15472
|
+
GeoJsonAdapter.prototype._selectOnLayerClick = function (e) {
|
|
15473
|
+
leafletSrc.exports.DomEvent.stopPropagation(e);
|
|
15474
|
+
var layer = e.target;
|
|
15475
|
+
var feature = layer.feature;
|
|
15476
|
+
var def = __assign({ target: this, layer: layer, feature: feature }, createFeaturePositionOptions(feature));
|
|
15477
|
+
var isSelected = this._getSelected(layer);
|
|
15478
|
+
if (isSelected) {
|
|
15479
|
+
if (this.options && this.options.unselectOnSecondClick) {
|
|
15480
|
+
this._unSelectLayer(isSelected);
|
|
15481
|
+
}
|
|
15482
|
+
}
|
|
15483
|
+
else {
|
|
15484
|
+
this._selectLayer(def, 'click', e.latlng);
|
|
15485
|
+
}
|
|
15486
|
+
};
|
|
15487
|
+
GeoJsonAdapter.prototype._selectLayer = function (def, type, latlng) {
|
|
15488
|
+
var _this = this;
|
|
15489
|
+
var multiselect = this.options.multiselect;
|
|
15490
|
+
if (!multiselect) {
|
|
15491
|
+
// To unselect layer on another layer click
|
|
15492
|
+
this.map._addUnselectCb(function () {
|
|
15493
|
+
_this._unSelectLayer(def);
|
|
15494
|
+
});
|
|
15495
|
+
this._selectedLayers.forEach(function (x) { return _this._unSelectLayer(x); });
|
|
15496
|
+
}
|
|
15497
|
+
this._selectedLayers.push(def);
|
|
15498
|
+
this.selected = true;
|
|
15499
|
+
var _a = this.options, selectedPaint = _a.selectedPaint, popupOnSelect = _a.popupOnSelect, popupOptions = _a.popupOptions;
|
|
15500
|
+
if (selectedPaint && def.layer) {
|
|
15501
|
+
this._setPaint(def, selectedPaint);
|
|
15502
|
+
}
|
|
15503
|
+
if (popupOnSelect) {
|
|
15504
|
+
this._openPopup(def, popupOptions, type, latlng);
|
|
15505
|
+
}
|
|
15506
|
+
if (this.options.onSelect) {
|
|
15507
|
+
var features = def.feature ? [def.feature] : [];
|
|
15508
|
+
this.options.onSelect(__assign({ type: type, layer: this, features: features }, createFeaturePositionOptions(features)));
|
|
15509
|
+
}
|
|
15510
|
+
};
|
|
15511
|
+
GeoJsonAdapter.prototype._unSelectLayer = function (def) {
|
|
15512
|
+
var index = this._selectedLayers.indexOf(def);
|
|
15513
|
+
if (index !== -1) {
|
|
15514
|
+
this._selectedLayers.splice(index, 1);
|
|
15515
|
+
if (this.options) {
|
|
15516
|
+
if (this.options.paint) {
|
|
15517
|
+
this._setPaint(def, this.options.paint);
|
|
15518
|
+
}
|
|
15519
|
+
if (this.options.popupOnSelect && def.layer) {
|
|
15520
|
+
this._removePopup(def.layer);
|
|
15521
|
+
}
|
|
15522
|
+
}
|
|
15523
|
+
}
|
|
15524
|
+
this.selected = this._selectedLayers.length > 0;
|
|
15525
|
+
};
|
|
15526
|
+
GeoJsonAdapter.prototype._createDivIcon = function (icon) {
|
|
15527
|
+
var toLIconOpt = __rest(icon, []);
|
|
15528
|
+
return new leafletSrc.exports.DivIcon(__assign({ className: '' }, toLIconOpt));
|
|
15529
|
+
};
|
|
15530
|
+
GeoJsonAdapter.prototype._createPaintToLayer = function (icon) {
|
|
15531
|
+
var _this = this;
|
|
15532
|
+
if (icon && icon.type) {
|
|
15533
|
+
if (icon.type === 'icon') {
|
|
15534
|
+
var iconClassName = icon.className;
|
|
15535
|
+
var html = icon.html;
|
|
15536
|
+
if (iconClassName || html) {
|
|
15537
|
+
return function (geoJsonPoint, latlng) {
|
|
15538
|
+
var divIcon = _this._createDivIcon(icon);
|
|
15539
|
+
return new leafletSrc.exports.Marker(latlng, { icon: divIcon });
|
|
15540
|
+
};
|
|
15541
|
+
}
|
|
15542
|
+
}
|
|
15543
|
+
else if (icon.type === 'pin') {
|
|
15544
|
+
return function (geoJsonPoint, latlng) {
|
|
15545
|
+
// const divIcon = this.createDivIcon(icon);
|
|
15546
|
+
return new leafletSrc.exports.Marker(latlng);
|
|
15547
|
+
};
|
|
15548
|
+
}
|
|
15549
|
+
}
|
|
15550
|
+
return function (geoJsonPoint, latlng) {
|
|
15551
|
+
var p = PAINT;
|
|
15552
|
+
return new leafletSrc.exports.CircleMarker(latlng, _this._preparePaint(__assign(__assign({}, p), icon)));
|
|
15553
|
+
};
|
|
15554
|
+
};
|
|
15555
|
+
GeoJsonAdapter.prototype._createPaintOptions = function (paintOptions, type) {
|
|
15556
|
+
var geoJsonOptions = {};
|
|
15557
|
+
var paint = (paintOptions && this._preparePaint(paintOptions)) || {};
|
|
15558
|
+
if (paintOptions) {
|
|
15559
|
+
geoJsonOptions.style = function () {
|
|
15560
|
+
return paint;
|
|
15561
|
+
};
|
|
15562
|
+
}
|
|
15563
|
+
if (type === 'point') {
|
|
15564
|
+
geoJsonOptions.pointToLayer = this._createPaintToLayer(paintOptions);
|
|
15565
|
+
}
|
|
15566
|
+
else if (type === 'line') {
|
|
15567
|
+
paint.stroke = true;
|
|
15568
|
+
}
|
|
15569
|
+
return geoJsonOptions;
|
|
15570
|
+
};
|
|
15571
|
+
GeoJsonAdapter.prototype._addMapClickListener = function () {
|
|
15572
|
+
var map = this.map;
|
|
15573
|
+
if (map) {
|
|
15574
|
+
var unselectOnClick = this.options.unselectOnClick;
|
|
15575
|
+
var uoc = unselectOnClick !== null && unselectOnClick !== void 0 ? unselectOnClick : true;
|
|
15576
|
+
if (uoc) {
|
|
15577
|
+
map.on('click', this.$unselect);
|
|
15578
|
+
}
|
|
15579
|
+
}
|
|
15580
|
+
};
|
|
15581
|
+
GeoJsonAdapter.prototype._removeMapClickListener = function () {
|
|
15582
|
+
this.map.off('zoomend', this.$updateTooltip);
|
|
15583
|
+
this.map.off('moveend', this.$updateTooltip);
|
|
15584
|
+
this.map.off('click', this.$unselect);
|
|
15585
|
+
};
|
|
15586
|
+
GeoJsonAdapter.prototype._addMapListener = function () {
|
|
15587
|
+
var map = this.map;
|
|
15588
|
+
if (map) {
|
|
15589
|
+
var _a = this.options, labelField = _a.labelField, labelOnHover = _a.labelOnHover;
|
|
15590
|
+
this._addMapClickListener();
|
|
15591
|
+
if (labelField && !labelOnHover) {
|
|
15592
|
+
map.on('zoomend', this.$updateTooltip);
|
|
15593
|
+
map.on('moveend', this.$updateTooltip);
|
|
15594
|
+
}
|
|
15595
|
+
}
|
|
15596
|
+
};
|
|
15597
|
+
GeoJsonAdapter.prototype._removeMapListener = function () {
|
|
15598
|
+
this._removeMapClickListener();
|
|
15599
|
+
this.map.off('zoomend', this.$updateTooltip);
|
|
15600
|
+
this.map.off('moveend', this.$updateTooltip);
|
|
15601
|
+
};
|
|
15602
|
+
return GeoJsonAdapter;
|
|
15874
15603
|
}(BaseAdapter));
|
|
15875
15604
|
|
|
15876
|
-
function
|
|
15877
|
-
|
|
15878
|
-
|
|
15879
|
-
|
|
15880
|
-
|
|
15881
|
-
|
|
15882
|
-
|
|
15883
|
-
|
|
15884
|
-
|
|
15885
|
-
|
|
15886
|
-
|
|
15887
|
-
|
|
15888
|
-
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
|
|
15892
|
-
|
|
15893
|
-
|
|
15894
|
-
|
|
15895
|
-
}, _this.options.setViewDelay);
|
|
15896
|
-
}
|
|
15897
|
-
return _this;
|
|
15898
|
-
}
|
|
15899
|
-
RemoteTileLayer.prototype.createTile = function (coords, done) {
|
|
15900
|
-
// @ts-ignore
|
|
15901
|
-
var url = this.getTileUrl(coords);
|
|
15902
|
-
var tile = document.createElement('img');
|
|
15903
|
-
tile.abort = callAjax(url, function (response) {
|
|
15904
|
-
tile.src = response;
|
|
15905
|
-
done(null, tile);
|
|
15906
|
-
},
|
|
15907
|
-
// @ts-ignore
|
|
15908
|
-
this.options.headers);
|
|
15909
|
-
if (this.options.crossOrigin || this.options.crossOrigin === '') {
|
|
15910
|
-
tile.crossOrigin =
|
|
15911
|
-
this.options.crossOrigin === true ? '' : this.options.crossOrigin;
|
|
15912
|
-
}
|
|
15913
|
-
tile.alt = '';
|
|
15914
|
-
tile.setAttribute('role', 'presentation');
|
|
15915
|
-
return tile;
|
|
15916
|
-
};
|
|
15917
|
-
RemoteTileLayer.prototype._abortLoading = function () {
|
|
15918
|
-
// @ts-ignore
|
|
15919
|
-
var tiles = this._tiles;
|
|
15920
|
-
// @ts-ignore
|
|
15921
|
-
var tileZoom = this._tileZoom;
|
|
15922
|
-
for (var i in tiles) {
|
|
15923
|
-
if (tiles[i].coords.z !== tileZoom) {
|
|
15924
|
-
var tile = tiles[i].el;
|
|
15925
|
-
tile.onload = leafletSrc.exports.Util.falseFn;
|
|
15926
|
-
tile.onerror = leafletSrc.exports.Util.falseFn;
|
|
15927
|
-
if (!tile.complete) {
|
|
15928
|
-
if (tile.abort) {
|
|
15929
|
-
tile.abort();
|
|
15930
|
-
}
|
|
15931
|
-
tile.src = leafletSrc.exports.Util.emptyImageUrl;
|
|
15932
|
-
leafletSrc.exports.DomUtil.remove(tile);
|
|
15933
|
-
delete tiles[i];
|
|
15934
|
-
}
|
|
15935
|
-
}
|
|
15936
|
-
}
|
|
15937
|
-
};
|
|
15938
|
-
return RemoteTileLayer;
|
|
15939
|
-
}(Base));
|
|
15605
|
+
function callAjax(src, callback, headers) {
|
|
15606
|
+
var xhr = new XMLHttpRequest();
|
|
15607
|
+
xhr.open('GET', src);
|
|
15608
|
+
xhr.responseType = 'arraybuffer';
|
|
15609
|
+
for (var h in headers) {
|
|
15610
|
+
xhr.setRequestHeader(h, headers[h]);
|
|
15611
|
+
}
|
|
15612
|
+
xhr.onload = function () {
|
|
15613
|
+
var arrayBufferView = new Uint8Array(this.response);
|
|
15614
|
+
var blob = new Blob([arrayBufferView], { type: 'image/png' });
|
|
15615
|
+
// @ts-ignore for typedoc
|
|
15616
|
+
var urlCreator = window.URL || window.webkitURL;
|
|
15617
|
+
var imageUrl = urlCreator.createObjectURL(blob);
|
|
15618
|
+
callback(imageUrl);
|
|
15619
|
+
};
|
|
15620
|
+
xhr.send();
|
|
15621
|
+
return function () {
|
|
15622
|
+
xhr.abort();
|
|
15623
|
+
};
|
|
15940
15624
|
}
|
|
15941
15625
|
|
|
15942
|
-
var
|
|
15943
|
-
__extends(
|
|
15944
|
-
function
|
|
15945
|
-
var _this = _super.call(this,
|
|
15946
|
-
|
|
15947
|
-
return _this;
|
|
15948
|
-
}
|
|
15949
|
-
|
|
15950
|
-
|
|
15626
|
+
var ImageOverlay = /** @class */ (function (_super) {
|
|
15627
|
+
__extends(ImageOverlay, _super);
|
|
15628
|
+
function ImageOverlay(imageUrl, bounds, options) {
|
|
15629
|
+
var _this = _super.call(this, imageUrl, bounds, options) || this;
|
|
15630
|
+
_this._abort = [];
|
|
15631
|
+
return _this;
|
|
15632
|
+
}
|
|
15633
|
+
ImageOverlay.prototype.cancelLoad = function () {
|
|
15634
|
+
if (this._abort) {
|
|
15635
|
+
this._abort.forEach(function (x) { return x(); });
|
|
15636
|
+
this._abort = [];
|
|
15637
|
+
}
|
|
15638
|
+
};
|
|
15639
|
+
ImageOverlay.prototype._initImage = function () {
|
|
15640
|
+
// @ts-ignore
|
|
15641
|
+
_super.prototype._initImage.call(this);
|
|
15642
|
+
// @ts-ignore
|
|
15643
|
+
var headers = this.options.headers;
|
|
15644
|
+
if (headers) {
|
|
15645
|
+
// @ts-ignore
|
|
15646
|
+
var img_1 = this._image;
|
|
15647
|
+
var src = img_1.src;
|
|
15648
|
+
img_1.src = '';
|
|
15649
|
+
this._abort.push(callAjax(src, function (response) {
|
|
15650
|
+
img_1.src = response;
|
|
15651
|
+
}, headers));
|
|
15652
|
+
}
|
|
15653
|
+
};
|
|
15654
|
+
return ImageOverlay;
|
|
15655
|
+
}(leafletSrc.exports.ImageOverlay));
|
|
15656
|
+
|
|
15657
|
+
/*!
|
|
15658
|
+
* leaflet.wms.js
|
|
15659
|
+
* A collection of Leaflet utilities for working with Web Mapping services.
|
|
15660
|
+
* (c) 2014-2016, Houston Engineering, Inc.
|
|
15661
|
+
* MIT License
|
|
15662
|
+
*/
|
|
15663
|
+
/*
|
|
15664
|
+
* Overlay:
|
|
15665
|
+
* "Single Tile" WMS image overlay that updates with map changes.
|
|
15666
|
+
* Portions of wms.Overlay are directly extracted from L.TileLayer.WMS.
|
|
15667
|
+
* See Leaflet license.
|
|
15668
|
+
*/
|
|
15669
|
+
var ImageLayer = /** @class */ (function (_super) {
|
|
15670
|
+
__extends(ImageLayer, _super);
|
|
15671
|
+
function ImageLayer(url, options) {
|
|
15672
|
+
var _this = _super.call(this, options) || this;
|
|
15673
|
+
_this.defaultWmsParams = {
|
|
15674
|
+
service: 'WMS',
|
|
15675
|
+
request: 'GetMap',
|
|
15676
|
+
version: '1.1.1',
|
|
15677
|
+
layers: '',
|
|
15678
|
+
styles: '',
|
|
15679
|
+
format: 'image/jpeg',
|
|
15680
|
+
transparent: false,
|
|
15681
|
+
};
|
|
15682
|
+
_this.options = {
|
|
15683
|
+
crs: null,
|
|
15684
|
+
uppercase: false,
|
|
15685
|
+
attribution: '',
|
|
15686
|
+
opacity: 1,
|
|
15687
|
+
isBack: false,
|
|
15688
|
+
minZoom: 0,
|
|
15689
|
+
pane: 'tilePane',
|
|
15690
|
+
headers: null,
|
|
15691
|
+
viewPortBuffer: 0,
|
|
15692
|
+
setViewDelay: 100,
|
|
15693
|
+
};
|
|
15694
|
+
_this._url = url;
|
|
15695
|
+
// Move WMS parameters to params object
|
|
15696
|
+
var params = {};
|
|
15697
|
+
var opts = {};
|
|
15698
|
+
var opt;
|
|
15699
|
+
for (opt in options) {
|
|
15700
|
+
if (opt in _this.options) {
|
|
15701
|
+
opts[opt] = options[opt];
|
|
15702
|
+
}
|
|
15703
|
+
else {
|
|
15704
|
+
params[opt] = options[opt];
|
|
15705
|
+
}
|
|
15706
|
+
}
|
|
15707
|
+
leafletSrc.exports.Util.setOptions(_this, opts);
|
|
15708
|
+
_this.wmsParams = leafletSrc.exports.Util.extend({}, _this.defaultWmsParams, params);
|
|
15709
|
+
return _this;
|
|
15710
|
+
}
|
|
15711
|
+
ImageLayer.prototype.setParams = function (params) {
|
|
15712
|
+
leafletSrc.exports.Util.extend(this.wmsParams, params);
|
|
15713
|
+
this.update();
|
|
15714
|
+
};
|
|
15715
|
+
ImageLayer.prototype.getAttribution = function () {
|
|
15716
|
+
return this.options.attribution || '';
|
|
15717
|
+
};
|
|
15718
|
+
ImageLayer.prototype.onAdd = function () {
|
|
15719
|
+
this.update();
|
|
15720
|
+
return this;
|
|
15721
|
+
};
|
|
15722
|
+
ImageLayer.prototype.onRemove = function (map) {
|
|
15723
|
+
if (this._currentOverlay) {
|
|
15724
|
+
this._currentOverlay.cancelLoad();
|
|
15725
|
+
map.removeLayer(this._currentOverlay);
|
|
15726
|
+
delete this._currentOverlay;
|
|
15727
|
+
}
|
|
15728
|
+
if (this._currentUrl) {
|
|
15729
|
+
delete this._currentUrl;
|
|
15730
|
+
}
|
|
15731
|
+
return this;
|
|
15732
|
+
};
|
|
15733
|
+
ImageLayer.prototype.getEvents = function () {
|
|
15734
|
+
return {
|
|
15735
|
+
moveend: debounce(this.update, this.options.setViewDelay),
|
|
15736
|
+
};
|
|
15737
|
+
};
|
|
15738
|
+
ImageLayer.prototype.update = function () {
|
|
15739
|
+
var _this = this;
|
|
15740
|
+
if (!this._map) {
|
|
15741
|
+
return;
|
|
15742
|
+
}
|
|
15743
|
+
// Determine image URL and whether it has changed since last update
|
|
15744
|
+
this.updateWmsParams();
|
|
15745
|
+
var url = this.getImageUrl();
|
|
15746
|
+
if (this._currentUrl === url) {
|
|
15747
|
+
return;
|
|
15748
|
+
}
|
|
15749
|
+
this._currentUrl = url;
|
|
15750
|
+
// Keep current image overlay in place until new one loads
|
|
15751
|
+
// (inspired by esri.leaflet)
|
|
15752
|
+
var viewPortBuffer = this.options.viewPortBuffer || 0;
|
|
15753
|
+
var bounds = this._map.getBounds().pad(viewPortBuffer);
|
|
15754
|
+
var overlay = new ImageOverlay(url, bounds, {
|
|
15755
|
+
opacity: 0,
|
|
15756
|
+
pane: this.options.pane,
|
|
15757
|
+
headers: this.options.headers,
|
|
15758
|
+
});
|
|
15759
|
+
overlay.addTo(this._map);
|
|
15760
|
+
if (this._currentOverlay) {
|
|
15761
|
+
this._currentOverlay.cancelLoad();
|
|
15762
|
+
}
|
|
15763
|
+
overlay.once('load', function () {
|
|
15764
|
+
if (!_this._map) {
|
|
15765
|
+
return;
|
|
15766
|
+
}
|
|
15767
|
+
// @ts-ignore
|
|
15768
|
+
if (overlay._url !== _this._currentUrl) {
|
|
15769
|
+
_this._map.removeLayer(overlay);
|
|
15770
|
+
return;
|
|
15771
|
+
}
|
|
15772
|
+
else if (_this._currentOverlay) {
|
|
15773
|
+
_this._map.removeLayer(_this._currentOverlay);
|
|
15774
|
+
}
|
|
15775
|
+
_this._currentOverlay = overlay;
|
|
15776
|
+
overlay.setOpacity(_this.options.opacity !== undefined ? _this.options.opacity : 1);
|
|
15777
|
+
if (_this.options.isBack === true) {
|
|
15778
|
+
overlay.bringToBack();
|
|
15779
|
+
}
|
|
15780
|
+
if (_this.options.isBack === false) {
|
|
15781
|
+
overlay.bringToFront();
|
|
15782
|
+
}
|
|
15783
|
+
if (_this.options.zIndex !== undefined) {
|
|
15784
|
+
overlay.setZIndex(_this.options.zIndex);
|
|
15785
|
+
}
|
|
15786
|
+
}, this);
|
|
15787
|
+
var _a = this.options, minZoom = _a.minZoom, maxZoom = _a.maxZoom;
|
|
15788
|
+
if ((minZoom && this._map.getZoom() < minZoom) ||
|
|
15789
|
+
(maxZoom && this._map.getZoom() > maxZoom)) {
|
|
15790
|
+
this._map.removeLayer(overlay);
|
|
15791
|
+
}
|
|
15792
|
+
};
|
|
15793
|
+
ImageLayer.prototype.setOpacity = function (opacity) {
|
|
15794
|
+
this.options.opacity = opacity;
|
|
15795
|
+
if (this._currentOverlay) {
|
|
15796
|
+
this._currentOverlay.setOpacity(opacity);
|
|
15797
|
+
}
|
|
15798
|
+
};
|
|
15799
|
+
ImageLayer.prototype.bringToBack = function () {
|
|
15800
|
+
this.options.isBack = true;
|
|
15801
|
+
if (this._currentOverlay) {
|
|
15802
|
+
this._currentOverlay.bringToBack();
|
|
15803
|
+
}
|
|
15804
|
+
};
|
|
15805
|
+
ImageLayer.prototype.bringToFront = function () {
|
|
15806
|
+
this.options.isBack = false;
|
|
15807
|
+
if (this._currentOverlay) {
|
|
15808
|
+
this._currentOverlay.bringToFront();
|
|
15809
|
+
}
|
|
15810
|
+
};
|
|
15811
|
+
ImageLayer.prototype.setZIndex = function (zIndex) {
|
|
15812
|
+
this.options.zIndex = zIndex;
|
|
15813
|
+
if (this._currentOverlay) {
|
|
15814
|
+
this._currentOverlay.setZIndex(zIndex);
|
|
15815
|
+
}
|
|
15816
|
+
};
|
|
15817
|
+
// See L.TileLayer.WMS: onAdd() & getTileUrl()
|
|
15818
|
+
ImageLayer.prototype.updateWmsParams = function (map) {
|
|
15819
|
+
if (!map) {
|
|
15820
|
+
map = this._map;
|
|
15821
|
+
}
|
|
15822
|
+
// Compute WMS options
|
|
15823
|
+
var viewPortBuffer = this.options.viewPortBuffer || 0;
|
|
15824
|
+
var bounds = map.getBounds().pad(viewPortBuffer);
|
|
15825
|
+
var size = map.getSize();
|
|
15826
|
+
if (this.options.viewPortBuffer !== 0) {
|
|
15827
|
+
var factor = viewPortBuffer + 1;
|
|
15828
|
+
size.x = Math.ceil(size.x * factor);
|
|
15829
|
+
size.y = Math.ceil(size.y * factor);
|
|
15830
|
+
}
|
|
15831
|
+
var wmsVersion = parseFloat(this.wmsParams.version);
|
|
15832
|
+
var crs = this.options.crs || map.options.crs;
|
|
15833
|
+
var projectionKey = wmsVersion >= 1.3 ? 'crs' : 'srs';
|
|
15834
|
+
if (crs) {
|
|
15835
|
+
var nw = crs.project(bounds.getNorthWest());
|
|
15836
|
+
var se = crs.project(bounds.getSouthEast());
|
|
15837
|
+
// Assemble WMS parameter string
|
|
15838
|
+
var params = {
|
|
15839
|
+
width: size.x,
|
|
15840
|
+
height: size.y,
|
|
15841
|
+
};
|
|
15842
|
+
params[projectionKey] = crs.code;
|
|
15843
|
+
params.bbox = (wmsVersion >= 1.3 && crs === leafletSrc.exports.CRS.EPSG4326
|
|
15844
|
+
? [se.y, nw.x, nw.y, se.x]
|
|
15845
|
+
: [nw.x, se.y, se.x, nw.y]).join(',');
|
|
15846
|
+
leafletSrc.exports.Util.extend(this.wmsParams, params);
|
|
15847
|
+
}
|
|
15848
|
+
};
|
|
15849
|
+
ImageLayer.prototype.getImageUrl = function () {
|
|
15850
|
+
var uppercase = this.options.uppercase || false;
|
|
15851
|
+
var pstr = leafletSrc.exports.Util.getParamString(this.wmsParams, this._url, uppercase);
|
|
15852
|
+
return this._url + pstr;
|
|
15853
|
+
};
|
|
15854
|
+
return ImageLayer;
|
|
15855
|
+
}(leafletSrc.exports.Layer));
|
|
15856
|
+
|
|
15857
|
+
var ImageAdapter = /** @class */ (function (_super) {
|
|
15858
|
+
__extends(ImageAdapter, _super);
|
|
15859
|
+
function ImageAdapter() {
|
|
15860
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
15861
|
+
}
|
|
15862
|
+
ImageAdapter.prototype.addLayer = function (options) {
|
|
15863
|
+
var url = options && options.url;
|
|
15864
|
+
if (url) {
|
|
15865
|
+
options = __assign({ transparent: true }, options);
|
|
15866
|
+
var updateWmsParamsFromOpt_1 = options.updateWmsParams;
|
|
15867
|
+
this.layer = new ImageLayer(url, __assign(__assign(__assign({ pane: this.pane, headers: options.headers, setViewDelay: options.setViewDelay }, options), options.params), options.nativeOptions));
|
|
15868
|
+
if (updateWmsParamsFromOpt_1) {
|
|
15869
|
+
var updateWmsParams_1 = this.layer.updateWmsParams;
|
|
15870
|
+
this.layer.updateWmsParams = function (map) {
|
|
15871
|
+
updateWmsParams_1.call(this, map);
|
|
15872
|
+
this.wmsParams = updateWmsParamsFromOpt_1(this.wmsParams);
|
|
15873
|
+
};
|
|
15874
|
+
}
|
|
15875
|
+
return this.layer;
|
|
15876
|
+
}
|
|
15877
|
+
};
|
|
15878
|
+
return ImageAdapter;
|
|
15879
|
+
}(BaseAdapter));
|
|
15880
|
+
|
|
15881
|
+
function makeRemote(Base) {
|
|
15882
|
+
return /** @class */ (function (_super) {
|
|
15883
|
+
__extends(RemoteTileLayer, _super);
|
|
15884
|
+
function RemoteTileLayer() {
|
|
15885
|
+
var args = [];
|
|
15886
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
15887
|
+
args[_i] = arguments[_i];
|
|
15888
|
+
}
|
|
15889
|
+
var _this = _super.apply(this, args) || this;
|
|
15890
|
+
if (_this.options.setViewDelay) {
|
|
15891
|
+
// @ts-ignore
|
|
15892
|
+
_this._update = debounce(function () {
|
|
15893
|
+
var _a;
|
|
15894
|
+
var a = [];
|
|
15895
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
15896
|
+
a[_i] = arguments[_i];
|
|
15897
|
+
}
|
|
15898
|
+
// @ts-ignore
|
|
15899
|
+
(_a = leafletSrc.exports.GridLayer.prototype._update).call.apply(_a, __spreadArray([_this], a, false));
|
|
15900
|
+
}, _this.options.setViewDelay);
|
|
15901
|
+
}
|
|
15902
|
+
return _this;
|
|
15903
|
+
}
|
|
15904
|
+
RemoteTileLayer.prototype.createTile = function (coords, done) {
|
|
15905
|
+
// @ts-ignore
|
|
15906
|
+
var url = this.getTileUrl(coords);
|
|
15907
|
+
var tile = document.createElement('img');
|
|
15908
|
+
tile.abort = callAjax(url, function (response) {
|
|
15909
|
+
tile.src = response;
|
|
15910
|
+
done(null, tile);
|
|
15911
|
+
},
|
|
15912
|
+
// @ts-ignore
|
|
15913
|
+
this.options.headers);
|
|
15914
|
+
if (this.options.crossOrigin || this.options.crossOrigin === '') {
|
|
15915
|
+
tile.crossOrigin =
|
|
15916
|
+
this.options.crossOrigin === true ? '' : this.options.crossOrigin;
|
|
15917
|
+
}
|
|
15918
|
+
tile.alt = '';
|
|
15919
|
+
tile.setAttribute('role', 'presentation');
|
|
15920
|
+
return tile;
|
|
15921
|
+
};
|
|
15922
|
+
RemoteTileLayer.prototype._abortLoading = function () {
|
|
15923
|
+
// @ts-ignore
|
|
15924
|
+
var tiles = this._tiles;
|
|
15925
|
+
// @ts-ignore
|
|
15926
|
+
var tileZoom = this._tileZoom;
|
|
15927
|
+
for (var i in tiles) {
|
|
15928
|
+
if (tiles[i].coords.z !== tileZoom) {
|
|
15929
|
+
var tile = tiles[i].el;
|
|
15930
|
+
tile.onload = leafletSrc.exports.Util.falseFn;
|
|
15931
|
+
tile.onerror = leafletSrc.exports.Util.falseFn;
|
|
15932
|
+
if (!tile.complete) {
|
|
15933
|
+
if (tile.abort) {
|
|
15934
|
+
tile.abort();
|
|
15935
|
+
}
|
|
15936
|
+
tile.src = leafletSrc.exports.Util.emptyImageUrl;
|
|
15937
|
+
leafletSrc.exports.DomUtil.remove(tile);
|
|
15938
|
+
delete tiles[i];
|
|
15939
|
+
}
|
|
15940
|
+
}
|
|
15941
|
+
}
|
|
15942
|
+
};
|
|
15943
|
+
return RemoteTileLayer;
|
|
15944
|
+
}(Base));
|
|
15945
|
+
}
|
|
15946
|
+
|
|
15947
|
+
var TileLayerBase = /** @class */ (function (_super) {
|
|
15948
|
+
__extends(TileLayerBase, _super);
|
|
15949
|
+
function TileLayerBase(urlTemplate, options) {
|
|
15950
|
+
var _this = _super.call(this, urlTemplate, options) || this;
|
|
15951
|
+
Object.assign(_this.options, options);
|
|
15952
|
+
return _this;
|
|
15953
|
+
}
|
|
15954
|
+
return TileLayerBase;
|
|
15955
|
+
}(leafletSrc.exports.TileLayer));
|
|
15951
15956
|
var TileLayer = makeRemote(TileLayerBase);
|
|
15952
15957
|
|
|
15953
|
-
var TileAdapter = /** @class */ (function (_super) {
|
|
15954
|
-
__extends(TileAdapter, _super);
|
|
15955
|
-
function TileAdapter() {
|
|
15956
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
15957
|
-
}
|
|
15958
|
-
TileAdapter.prototype.addLayer = function (options) {
|
|
15959
|
-
this.options = Object.assign(this.options, options);
|
|
15960
|
-
if (options) {
|
|
15961
|
-
var url = options.url, opt = __rest(options, ["url"]);
|
|
15962
|
-
if (url) {
|
|
15963
|
-
var tileLayerOptions = __assign({ pane: this.pane, attribution: opt.attribution, minZoom: opt.minZoom, maxZoom: opt.maxZoom }, opt.nativeOptions);
|
|
15964
|
-
if (opt.subdomains) {
|
|
15965
|
-
tileLayerOptions.subdomains = opt.subdomains;
|
|
15966
|
-
}
|
|
15967
|
-
var layer = void 0;
|
|
15968
|
-
if (opt.headers) {
|
|
15969
|
-
layer = new TileLayer(url, __assign(__assign({}, tileLayerOptions), { headers: opt.headers, setViewDelay: opt.setViewDelay }));
|
|
15970
|
-
}
|
|
15971
|
-
else {
|
|
15972
|
-
layer = new leafletSrc.exports.TileLayer(url, tileLayerOptions);
|
|
15973
|
-
}
|
|
15974
|
-
return layer;
|
|
15975
|
-
}
|
|
15976
|
-
}
|
|
15977
|
-
};
|
|
15978
|
-
return TileAdapter;
|
|
15958
|
+
var TileAdapter = /** @class */ (function (_super) {
|
|
15959
|
+
__extends(TileAdapter, _super);
|
|
15960
|
+
function TileAdapter() {
|
|
15961
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
15962
|
+
}
|
|
15963
|
+
TileAdapter.prototype.addLayer = function (options) {
|
|
15964
|
+
this.options = Object.assign(this.options, options);
|
|
15965
|
+
if (options) {
|
|
15966
|
+
var url = options.url, opt = __rest(options, ["url"]);
|
|
15967
|
+
if (url) {
|
|
15968
|
+
var tileLayerOptions = __assign({ pane: this.pane, attribution: opt.attribution, minZoom: opt.minZoom, maxZoom: opt.maxZoom }, opt.nativeOptions);
|
|
15969
|
+
if (opt.subdomains) {
|
|
15970
|
+
tileLayerOptions.subdomains = opt.subdomains;
|
|
15971
|
+
}
|
|
15972
|
+
var layer = void 0;
|
|
15973
|
+
if (opt.headers) {
|
|
15974
|
+
layer = new TileLayer(url, __assign(__assign({}, tileLayerOptions), { headers: opt.headers, setViewDelay: opt.setViewDelay }));
|
|
15975
|
+
}
|
|
15976
|
+
else {
|
|
15977
|
+
layer = new leafletSrc.exports.TileLayer(url, tileLayerOptions);
|
|
15978
|
+
}
|
|
15979
|
+
return layer;
|
|
15980
|
+
}
|
|
15981
|
+
}
|
|
15982
|
+
};
|
|
15983
|
+
return TileAdapter;
|
|
15979
15984
|
}(BaseAdapter));
|
|
15980
15985
|
|
|
15981
|
-
var WmsLayerBase = /** @class */ (function (_super) {
|
|
15982
|
-
__extends(WmsLayerBase, _super);
|
|
15983
|
-
function WmsLayerBase(urlTemplate, options) {
|
|
15984
|
-
return _super.call(this, urlTemplate, options) || this;
|
|
15985
|
-
}
|
|
15986
|
-
return WmsLayerBase;
|
|
15987
|
-
}(leafletSrc.exports.TileLayer.WMS));
|
|
15986
|
+
var WmsLayerBase = /** @class */ (function (_super) {
|
|
15987
|
+
__extends(WmsLayerBase, _super);
|
|
15988
|
+
function WmsLayerBase(urlTemplate, options) {
|
|
15989
|
+
return _super.call(this, urlTemplate, options) || this;
|
|
15990
|
+
}
|
|
15991
|
+
return WmsLayerBase;
|
|
15992
|
+
}(leafletSrc.exports.TileLayer.WMS));
|
|
15988
15993
|
var WmsLayer = makeRemote(WmsLayerBase);
|
|
15989
15994
|
|
|
15990
|
-
var WmsAdapter = /** @class */ (function (_super) {
|
|
15991
|
-
__extends(WmsAdapter, _super);
|
|
15992
|
-
function WmsAdapter() {
|
|
15993
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
15994
|
-
}
|
|
15995
|
-
WmsAdapter.prototype.addLayer = function (options) {
|
|
15996
|
-
Object.assign(this.options, options);
|
|
15997
|
-
var url = options.url, opt = __rest(options, ["url"]);
|
|
15998
|
-
if (url) {
|
|
15999
|
-
var layerOptions = __assign({ pane: this.pane, attribution: opt.attribution, minZoom: opt.minZoom, maxZoom: opt.maxZoom, layers: options.layers, format: options.format }, options.nativeOptions);
|
|
16000
|
-
var layer = void 0;
|
|
16001
|
-
if (opt.headers) {
|
|
16002
|
-
layer = new WmsLayer(url, __assign(__assign({}, layerOptions), { headers: opt.headers }));
|
|
16003
|
-
}
|
|
16004
|
-
else {
|
|
16005
|
-
layer = new leafletSrc.exports.TileLayer.WMS(url, layerOptions);
|
|
16006
|
-
}
|
|
16007
|
-
return layer;
|
|
16008
|
-
}
|
|
16009
|
-
};
|
|
16010
|
-
return WmsAdapter;
|
|
15995
|
+
var WmsAdapter = /** @class */ (function (_super) {
|
|
15996
|
+
__extends(WmsAdapter, _super);
|
|
15997
|
+
function WmsAdapter() {
|
|
15998
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
15999
|
+
}
|
|
16000
|
+
WmsAdapter.prototype.addLayer = function (options) {
|
|
16001
|
+
Object.assign(this.options, options);
|
|
16002
|
+
var url = options.url, opt = __rest(options, ["url"]);
|
|
16003
|
+
if (url) {
|
|
16004
|
+
var layerOptions = __assign({ pane: this.pane, attribution: opt.attribution, minZoom: opt.minZoom, maxZoom: opt.maxZoom, layers: options.layers, format: options.format }, options.nativeOptions);
|
|
16005
|
+
var layer = void 0;
|
|
16006
|
+
if (opt.headers) {
|
|
16007
|
+
layer = new WmsLayer(url, __assign(__assign({}, layerOptions), { headers: opt.headers }));
|
|
16008
|
+
}
|
|
16009
|
+
else {
|
|
16010
|
+
layer = new leafletSrc.exports.TileLayer.WMS(url, layerOptions);
|
|
16011
|
+
}
|
|
16012
|
+
return layer;
|
|
16013
|
+
}
|
|
16014
|
+
};
|
|
16015
|
+
return WmsAdapter;
|
|
16011
16016
|
}(BaseAdapter));
|
|
16012
16017
|
|
|
16013
|
-
var OsmAdapter = /** @class */ (function (_super) {
|
|
16014
|
-
__extends(OsmAdapter, _super);
|
|
16015
|
-
function OsmAdapter() {
|
|
16016
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
16017
|
-
}
|
|
16018
|
-
OsmAdapter.prototype.addLayer = function (options) {
|
|
16019
|
-
var url = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
|
16020
|
-
return _super.prototype.addLayer.call(this, __assign(__assign({ name: 'OpenStreetMap', attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }, options), { url: url }));
|
|
16021
|
-
};
|
|
16022
|
-
return OsmAdapter;
|
|
16018
|
+
var OsmAdapter = /** @class */ (function (_super) {
|
|
16019
|
+
__extends(OsmAdapter, _super);
|
|
16020
|
+
function OsmAdapter() {
|
|
16021
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
16022
|
+
}
|
|
16023
|
+
OsmAdapter.prototype.addLayer = function (options) {
|
|
16024
|
+
var url = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
|
16025
|
+
return _super.prototype.addLayer.call(this, __assign(__assign({ name: 'OpenStreetMap', attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }, options), { url: url }));
|
|
16026
|
+
};
|
|
16027
|
+
return OsmAdapter;
|
|
16023
16028
|
}(TileAdapter));
|
|
16024
16029
|
|
|
16025
|
-
function arrayToBoundsExpression(bounds) {
|
|
16026
|
-
var e = bounds;
|
|
16027
|
-
// top, left, bottom, right
|
|
16028
|
-
return [
|
|
16029
|
-
[e[3], e[0]],
|
|
16030
|
-
[e[1], e[2]],
|
|
16031
|
-
];
|
|
16030
|
+
function arrayToBoundsExpression(bounds) {
|
|
16031
|
+
var e = bounds;
|
|
16032
|
+
// top, left, bottom, right
|
|
16033
|
+
return [
|
|
16034
|
+
[e[3], e[0]],
|
|
16035
|
+
[e[1], e[2]],
|
|
16036
|
+
];
|
|
16032
16037
|
}
|
|
16033
16038
|
|
|
16034
|
-
var LeafletMapAdapter$1 = /** @class */ (function () {
|
|
16035
|
-
function LeafletMapAdapter() {
|
|
16036
|
-
this.options = { target: 'map' };
|
|
16037
|
-
this.layerAdapters = LeafletMapAdapter.layerAdapters;
|
|
16038
|
-
this.controlAdapters = LeafletMapAdapter.controlAdapters;
|
|
16039
|
-
this.emitter = new events.exports.EventEmitter();
|
|
16040
|
-
this._unselectCb = [];
|
|
16041
|
-
this._universalEvents = [
|
|
16042
|
-
'move',
|
|
16043
|
-
'zoom',
|
|
16044
|
-
'zoomend',
|
|
16045
|
-
'zoomstart',
|
|
16046
|
-
'moveend',
|
|
16047
|
-
'movestart',
|
|
16048
|
-
];
|
|
16049
|
-
this._positionEvents = [
|
|
16050
|
-
'mousemove',
|
|
16051
|
-
'mouseout',
|
|
16052
|
-
'mouseover',
|
|
16053
|
-
];
|
|
16054
|
-
}
|
|
16055
|
-
LeafletMapAdapter.prototype.create = function (options) {
|
|
16056
|
-
var
|
|
16057
|
-
|
|
16058
|
-
|
|
16059
|
-
|
|
16060
|
-
this.
|
|
16061
|
-
|
|
16062
|
-
|
|
16063
|
-
|
|
16064
|
-
|
|
16065
|
-
this.map.
|
|
16066
|
-
|
|
16067
|
-
|
|
16068
|
-
|
|
16069
|
-
|
|
16070
|
-
this.
|
|
16071
|
-
|
|
16072
|
-
|
|
16073
|
-
|
|
16074
|
-
|
|
16075
|
-
|
|
16076
|
-
|
|
16077
|
-
|
|
16078
|
-
|
|
16079
|
-
|
|
16080
|
-
|
|
16081
|
-
|
|
16082
|
-
|
|
16083
|
-
|
|
16084
|
-
|
|
16085
|
-
|
|
16086
|
-
|
|
16087
|
-
|
|
16088
|
-
|
|
16089
|
-
|
|
16090
|
-
|
|
16091
|
-
|
|
16092
|
-
|
|
16093
|
-
|
|
16094
|
-
|
|
16095
|
-
|
|
16096
|
-
|
|
16097
|
-
|
|
16098
|
-
|
|
16099
|
-
|
|
16100
|
-
var
|
|
16101
|
-
|
|
16102
|
-
|
|
16103
|
-
|
|
16104
|
-
|
|
16105
|
-
|
|
16106
|
-
|
|
16107
|
-
|
|
16108
|
-
|
|
16109
|
-
|
|
16110
|
-
|
|
16111
|
-
|
|
16112
|
-
|
|
16113
|
-
|
|
16114
|
-
|
|
16115
|
-
|
|
16116
|
-
|
|
16117
|
-
|
|
16118
|
-
|
|
16119
|
-
|
|
16120
|
-
|
|
16121
|
-
|
|
16122
|
-
|
|
16123
|
-
|
|
16124
|
-
|
|
16125
|
-
|
|
16126
|
-
|
|
16127
|
-
|
|
16128
|
-
|
|
16129
|
-
|
|
16130
|
-
map.
|
|
16131
|
-
|
|
16132
|
-
|
|
16133
|
-
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
|
|
16137
|
-
|
|
16138
|
-
|
|
16139
|
-
|
|
16140
|
-
|
|
16141
|
-
|
|
16142
|
-
|
|
16143
|
-
|
|
16144
|
-
|
|
16145
|
-
|
|
16146
|
-
|
|
16147
|
-
|
|
16148
|
-
|
|
16149
|
-
|
|
16150
|
-
|
|
16151
|
-
|
|
16152
|
-
|
|
16153
|
-
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
var
|
|
16159
|
-
|
|
16160
|
-
|
|
16161
|
-
|
|
16162
|
-
|
|
16163
|
-
|
|
16164
|
-
|
|
16165
|
-
|
|
16166
|
-
|
|
16167
|
-
|
|
16168
|
-
|
|
16169
|
-
|
|
16170
|
-
|
|
16171
|
-
|
|
16172
|
-
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
var
|
|
16176
|
-
var
|
|
16177
|
-
|
|
16178
|
-
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16182
|
-
if (
|
|
16183
|
-
|
|
16184
|
-
var
|
|
16185
|
-
|
|
16186
|
-
|
|
16187
|
-
|
|
16188
|
-
|
|
16189
|
-
|
|
16190
|
-
|
|
16191
|
-
|
|
16192
|
-
|
|
16193
|
-
|
|
16194
|
-
|
|
16195
|
-
|
|
16196
|
-
|
|
16197
|
-
|
|
16198
|
-
|
|
16199
|
-
|
|
16200
|
-
|
|
16201
|
-
|
|
16202
|
-
|
|
16203
|
-
|
|
16204
|
-
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
16212
|
-
|
|
16213
|
-
|
|
16214
|
-
|
|
16215
|
-
|
|
16216
|
-
|
|
16217
|
-
|
|
16218
|
-
|
|
16219
|
-
|
|
16220
|
-
|
|
16221
|
-
|
|
16222
|
-
|
|
16223
|
-
|
|
16224
|
-
|
|
16225
|
-
|
|
16226
|
-
|
|
16227
|
-
|
|
16228
|
-
|
|
16229
|
-
|
|
16230
|
-
|
|
16231
|
-
|
|
16232
|
-
|
|
16233
|
-
|
|
16234
|
-
|
|
16235
|
-
|
|
16236
|
-
|
|
16237
|
-
|
|
16238
|
-
|
|
16239
|
-
|
|
16240
|
-
this.emitter.emit('
|
|
16241
|
-
|
|
16242
|
-
|
|
16243
|
-
|
|
16244
|
-
|
|
16245
|
-
|
|
16246
|
-
|
|
16247
|
-
|
|
16248
|
-
var
|
|
16249
|
-
|
|
16250
|
-
var
|
|
16251
|
-
|
|
16252
|
-
|
|
16253
|
-
|
|
16254
|
-
|
|
16255
|
-
|
|
16256
|
-
|
|
16257
|
-
|
|
16258
|
-
|
|
16259
|
-
|
|
16260
|
-
|
|
16261
|
-
|
|
16262
|
-
|
|
16263
|
-
|
|
16264
|
-
|
|
16265
|
-
|
|
16266
|
-
|
|
16267
|
-
|
|
16268
|
-
|
|
16269
|
-
|
|
16270
|
-
|
|
16271
|
-
|
|
16272
|
-
|
|
16273
|
-
|
|
16274
|
-
|
|
16275
|
-
|
|
16276
|
-
p
|
|
16277
|
-
|
|
16278
|
-
|
|
16279
|
-
this._unselectCb.
|
|
16280
|
-
|
|
16281
|
-
|
|
16282
|
-
|
|
16283
|
-
|
|
16284
|
-
var
|
|
16285
|
-
|
|
16286
|
-
|
|
16287
|
-
|
|
16288
|
-
|
|
16289
|
-
|
|
16290
|
-
|
|
16291
|
-
|
|
16292
|
-
|
|
16293
|
-
|
|
16294
|
-
|
|
16295
|
-
|
|
16296
|
-
|
|
16297
|
-
|
|
16298
|
-
|
|
16299
|
-
this._resizeObserver
|
|
16300
|
-
|
|
16301
|
-
|
|
16302
|
-
|
|
16303
|
-
|
|
16304
|
-
var
|
|
16305
|
-
|
|
16306
|
-
|
|
16307
|
-
|
|
16308
|
-
|
|
16309
|
-
|
|
16310
|
-
|
|
16311
|
-
|
|
16312
|
-
|
|
16313
|
-
|
|
16314
|
-
|
|
16315
|
-
|
|
16316
|
-
|
|
16317
|
-
|
|
16318
|
-
|
|
16319
|
-
|
|
16320
|
-
|
|
16321
|
-
|
|
16322
|
-
|
|
16323
|
-
|
|
16324
|
-
|
|
16325
|
-
|
|
16326
|
-
|
|
16327
|
-
|
|
16328
|
-
|
|
16329
|
-
|
|
16330
|
-
|
|
16331
|
-
|
|
16332
|
-
|
|
16333
|
-
|
|
16334
|
-
|
|
16335
|
-
|
|
16336
|
-
|
|
16337
|
-
|
|
16338
|
-
|
|
16339
|
-
|
|
16340
|
-
|
|
16039
|
+
var LeafletMapAdapter$1 = /** @class */ (function () {
|
|
16040
|
+
function LeafletMapAdapter() {
|
|
16041
|
+
this.options = { target: 'map' };
|
|
16042
|
+
this.layerAdapters = LeafletMapAdapter.layerAdapters;
|
|
16043
|
+
this.controlAdapters = LeafletMapAdapter.controlAdapters;
|
|
16044
|
+
this.emitter = new events.exports.EventEmitter();
|
|
16045
|
+
this._unselectCb = [];
|
|
16046
|
+
this._universalEvents = [
|
|
16047
|
+
'move',
|
|
16048
|
+
'zoom',
|
|
16049
|
+
'zoomend',
|
|
16050
|
+
'zoomstart',
|
|
16051
|
+
'moveend',
|
|
16052
|
+
'movestart',
|
|
16053
|
+
];
|
|
16054
|
+
this._positionEvents = [
|
|
16055
|
+
'mousemove',
|
|
16056
|
+
'mouseout',
|
|
16057
|
+
'mouseover',
|
|
16058
|
+
];
|
|
16059
|
+
}
|
|
16060
|
+
LeafletMapAdapter.prototype.create = function (options) {
|
|
16061
|
+
var _a;
|
|
16062
|
+
var _this = this;
|
|
16063
|
+
this.options = __assign({}, options);
|
|
16064
|
+
if (this.options.target) {
|
|
16065
|
+
var zoom = (_a = this.options, _a.zoom), center = _a.center, maxZoom = _a.maxZoom, minZoom = _a.minZoom, mb = _a.maxBounds, mapAdapterOptions = _a.mapAdapterOptions;
|
|
16066
|
+
this.map =
|
|
16067
|
+
this.options.map ||
|
|
16068
|
+
new leafletSrc.exports.Map(this.options.target, __assign({ attributionControl: false, zoomControl: false, maxBounds: mb ? arrayToBoundsExpression(mb) : undefined, maxZoom: maxZoom, minZoom: minZoom, center: center && [center[1], center[0]], zoom: zoom }, mapAdapterOptions));
|
|
16069
|
+
// create default pane
|
|
16070
|
+
var defPane = this.map.createPane('order-0');
|
|
16071
|
+
this.map._addUnselectCb = function (def) {
|
|
16072
|
+
_this._addUnselectCb(def);
|
|
16073
|
+
};
|
|
16074
|
+
defPane.style.zIndex = String(0);
|
|
16075
|
+
this.emitter.emit('create', this);
|
|
16076
|
+
this._addMapListeners();
|
|
16077
|
+
}
|
|
16078
|
+
};
|
|
16079
|
+
LeafletMapAdapter.prototype.destroy = function () {
|
|
16080
|
+
if (this.map) {
|
|
16081
|
+
this.map.remove();
|
|
16082
|
+
}
|
|
16083
|
+
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
16084
|
+
};
|
|
16085
|
+
LeafletMapAdapter.prototype.getContainer = function () {
|
|
16086
|
+
return this.map && this.map.getContainer();
|
|
16087
|
+
};
|
|
16088
|
+
LeafletMapAdapter.prototype.getControlContainer = function () {
|
|
16089
|
+
var controlContainer = this.map && this.map._controlContainer;
|
|
16090
|
+
if (controlContainer) {
|
|
16091
|
+
return controlContainer;
|
|
16092
|
+
}
|
|
16093
|
+
throw new Error('Leaflet Map is not initialized yet');
|
|
16094
|
+
};
|
|
16095
|
+
LeafletMapAdapter.prototype.setCursor = function (cursor) {
|
|
16096
|
+
if (this.map) {
|
|
16097
|
+
this.map.getContainer().style.cursor = cursor;
|
|
16098
|
+
}
|
|
16099
|
+
};
|
|
16100
|
+
LeafletMapAdapter.prototype.setView = function (lngLatOrOpt, zoom) {
|
|
16101
|
+
var map = this.map;
|
|
16102
|
+
if (!map)
|
|
16103
|
+
return;
|
|
16104
|
+
if (Array.isArray(lngLatOrOpt)) {
|
|
16105
|
+
var lngLat = lngLatOrOpt;
|
|
16106
|
+
var lng = lngLat[0], lat = lngLat[1];
|
|
16107
|
+
if (this.map) {
|
|
16108
|
+
if (typeof zoom === 'number') {
|
|
16109
|
+
this.map.setView([lat, lng], zoom, { animate: false });
|
|
16110
|
+
}
|
|
16111
|
+
else {
|
|
16112
|
+
this.setCenter([lng, lat]);
|
|
16113
|
+
}
|
|
16114
|
+
}
|
|
16115
|
+
}
|
|
16116
|
+
else {
|
|
16117
|
+
var zoom_1 = lngLatOrOpt.zoom, center = lngLatOrOpt.center, maxBounds = lngLatOrOpt.maxBounds, bounds = lngLatOrOpt.bounds, minZoom = lngLatOrOpt.minZoom, maxZoom = lngLatOrOpt.maxZoom;
|
|
16118
|
+
if (center && zoom_1 !== undefined) {
|
|
16119
|
+
this.setView(center, zoom_1);
|
|
16120
|
+
}
|
|
16121
|
+
else {
|
|
16122
|
+
if (zoom_1 !== undefined) {
|
|
16123
|
+
this.setZoom(zoom_1);
|
|
16124
|
+
}
|
|
16125
|
+
if (center) {
|
|
16126
|
+
this.setCenter(center);
|
|
16127
|
+
}
|
|
16128
|
+
}
|
|
16129
|
+
if (bounds) {
|
|
16130
|
+
this.fitBounds(bounds);
|
|
16131
|
+
}
|
|
16132
|
+
if (maxBounds !== undefined) {
|
|
16133
|
+
if (maxBounds) {
|
|
16134
|
+
var b = arrayToBoundsExpression(maxBounds);
|
|
16135
|
+
map.setMaxBounds(b);
|
|
16136
|
+
map.setMinZoom(map.getBoundsZoom(b));
|
|
16137
|
+
this._watchSizeChangeToUpdateMinZoom(b);
|
|
16138
|
+
}
|
|
16139
|
+
else {
|
|
16140
|
+
// @ts-ignore `null` works for unset maxBounds, but not in typing
|
|
16141
|
+
map.setMaxBounds(null);
|
|
16142
|
+
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
16143
|
+
}
|
|
16144
|
+
}
|
|
16145
|
+
if (maxZoom !== undefined) {
|
|
16146
|
+
map.setMaxZoom(maxZoom);
|
|
16147
|
+
}
|
|
16148
|
+
if (minZoom !== undefined) {
|
|
16149
|
+
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
16150
|
+
map.setMinZoom(minZoom);
|
|
16151
|
+
}
|
|
16152
|
+
}
|
|
16153
|
+
};
|
|
16154
|
+
LeafletMapAdapter.prototype.setCenter = function (lngLat) {
|
|
16155
|
+
var lng = lngLat[0], lat = lngLat[1];
|
|
16156
|
+
if (this.map) {
|
|
16157
|
+
this.map.panTo([lat, lng]);
|
|
16158
|
+
}
|
|
16159
|
+
};
|
|
16160
|
+
LeafletMapAdapter.prototype.getCenter = function () {
|
|
16161
|
+
var map = this.map;
|
|
16162
|
+
if (map) {
|
|
16163
|
+
var bounds = map.getBounds();
|
|
16164
|
+
var center = bounds.getCenter();
|
|
16165
|
+
return [center.lng, center.lat];
|
|
16166
|
+
}
|
|
16167
|
+
};
|
|
16168
|
+
LeafletMapAdapter.prototype.setZoom = function (zoom) {
|
|
16169
|
+
if (this.map) {
|
|
16170
|
+
this.map.setZoom(zoom);
|
|
16171
|
+
}
|
|
16172
|
+
};
|
|
16173
|
+
LeafletMapAdapter.prototype.getZoom = function () {
|
|
16174
|
+
var _a;
|
|
16175
|
+
return (_a = (this.map && this.map.getZoom())) !== null && _a !== void 0 ? _a : undefined;
|
|
16176
|
+
};
|
|
16177
|
+
LeafletMapAdapter.prototype.getBounds = function () {
|
|
16178
|
+
if (!this.map)
|
|
16179
|
+
return undefined;
|
|
16180
|
+
var b = this.map.getBounds();
|
|
16181
|
+
var sw = b.getSouthWest();
|
|
16182
|
+
var ne = b.getNorthEast();
|
|
16183
|
+
return [sw.lng, sw.lat, ne.lng, ne.lat];
|
|
16184
|
+
};
|
|
16185
|
+
// [west, south, east, north]
|
|
16186
|
+
LeafletMapAdapter.prototype.fitBounds = function (bounds, options) {
|
|
16187
|
+
if (options === void 0) { options = {}; }
|
|
16188
|
+
if (this.map) {
|
|
16189
|
+
var maxZoom = options.maxZoom, offset = options.offset, padding = options.padding;
|
|
16190
|
+
var opt = {};
|
|
16191
|
+
if (maxZoom) {
|
|
16192
|
+
opt.maxZoom = maxZoom;
|
|
16193
|
+
}
|
|
16194
|
+
if (padding) {
|
|
16195
|
+
opt.padding = [padding, padding];
|
|
16196
|
+
}
|
|
16197
|
+
if (offset) {
|
|
16198
|
+
opt.padding = offset;
|
|
16199
|
+
}
|
|
16200
|
+
this.map.fitBounds(arrayToBoundsExpression(bounds), opt);
|
|
16201
|
+
}
|
|
16202
|
+
};
|
|
16203
|
+
LeafletMapAdapter.prototype.getLayerAdapter = function (name) {
|
|
16204
|
+
return LeafletMapAdapter.layerAdapters[name];
|
|
16205
|
+
};
|
|
16206
|
+
LeafletMapAdapter.prototype.createControl = function (control, options) {
|
|
16207
|
+
return createControl(control, options, this);
|
|
16208
|
+
};
|
|
16209
|
+
LeafletMapAdapter.prototype.createButtonControl = function (options) {
|
|
16210
|
+
return createButtonControl(options, this);
|
|
16211
|
+
};
|
|
16212
|
+
LeafletMapAdapter.prototype.addControl = function (control, position) {
|
|
16213
|
+
control.options.position = position.replace('-', '');
|
|
16214
|
+
if (this.map) {
|
|
16215
|
+
this.map.addControl(control);
|
|
16216
|
+
return control;
|
|
16217
|
+
}
|
|
16218
|
+
};
|
|
16219
|
+
LeafletMapAdapter.prototype.removeControl = function (control) {
|
|
16220
|
+
if (this.map) {
|
|
16221
|
+
this.map.removeControl(control);
|
|
16222
|
+
}
|
|
16223
|
+
};
|
|
16224
|
+
LeafletMapAdapter.prototype.removeLayer = function (layer) {
|
|
16225
|
+
layer && layer.remove && layer.remove();
|
|
16226
|
+
};
|
|
16227
|
+
LeafletMapAdapter.prototype.showLayer = function (layer) {
|
|
16228
|
+
if (this.map) {
|
|
16229
|
+
layer.addTo(this.map);
|
|
16230
|
+
}
|
|
16231
|
+
};
|
|
16232
|
+
LeafletMapAdapter.prototype.hideLayer = function (layer) {
|
|
16233
|
+
layer.remove();
|
|
16234
|
+
};
|
|
16235
|
+
LeafletMapAdapter.prototype.setLayerOpacity = function (layer, value) {
|
|
16236
|
+
if ('setOpacity' in layer) {
|
|
16237
|
+
layer.setOpacity(value);
|
|
16238
|
+
}
|
|
16239
|
+
};
|
|
16240
|
+
LeafletMapAdapter.prototype.setLayerOrder = function (layer, order, layers) {
|
|
16241
|
+
//
|
|
16242
|
+
};
|
|
16243
|
+
LeafletMapAdapter.prototype.onMapClick = function (evt) {
|
|
16244
|
+
var converted = convertMapClickEvent(evt);
|
|
16245
|
+
this.emitter.emit('preclick', converted);
|
|
16246
|
+
this.emitter.emit('click', converted);
|
|
16247
|
+
};
|
|
16248
|
+
LeafletMapAdapter.prototype.locate = function (opt, events) {
|
|
16249
|
+
var map = this.map;
|
|
16250
|
+
if (map) {
|
|
16251
|
+
map.locate(opt);
|
|
16252
|
+
if (events) {
|
|
16253
|
+
var locationfound_1 = events.locationfound, locationerror_1 = events.locationerror;
|
|
16254
|
+
var locationFound_1 = function (e) {
|
|
16255
|
+
var event = e;
|
|
16256
|
+
var lngLat = [event.latlng.lng, event.latlng.lat];
|
|
16257
|
+
locationfound_1({ lngLat: lngLat });
|
|
16258
|
+
};
|
|
16259
|
+
if (locationfound_1 !== undefined) {
|
|
16260
|
+
map.on('locationfound', locationFound_1, this);
|
|
16261
|
+
}
|
|
16262
|
+
if (locationerror_1) {
|
|
16263
|
+
map.on('locationerror', locationerror_1, this);
|
|
16264
|
+
}
|
|
16265
|
+
var stop_1 = function () {
|
|
16266
|
+
if (locationfound_1 !== undefined) {
|
|
16267
|
+
map.off('locationfound', locationFound_1);
|
|
16268
|
+
}
|
|
16269
|
+
if (locationerror_1) {
|
|
16270
|
+
map.off('locationerror', locationerror_1);
|
|
16271
|
+
}
|
|
16272
|
+
};
|
|
16273
|
+
return { stop: stop_1 };
|
|
16274
|
+
}
|
|
16275
|
+
}
|
|
16276
|
+
var stop = function () { return void 'fake function'; };
|
|
16277
|
+
return { stop: stop };
|
|
16278
|
+
};
|
|
16279
|
+
LeafletMapAdapter.prototype._addUnselectCb = function (cb) {
|
|
16280
|
+
for (var _i = 0, _a = this._unselectCb; _i < _a.length; _i++) {
|
|
16281
|
+
var p = _a[_i];
|
|
16282
|
+
p();
|
|
16283
|
+
}
|
|
16284
|
+
this._unselectCb.length = 0;
|
|
16285
|
+
this._unselectCb.push(cb);
|
|
16286
|
+
};
|
|
16287
|
+
LeafletMapAdapter.prototype._watchSizeChangeToUpdateMinZoom = function (bounds) {
|
|
16288
|
+
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
16289
|
+
var container = this.getContainer();
|
|
16290
|
+
var map = this.map;
|
|
16291
|
+
if (container && map && window.ResizeObserver) {
|
|
16292
|
+
this._resizeObserver = new ResizeObserver(function () {
|
|
16293
|
+
map.setMinZoom(map.getBoundsZoom(bounds));
|
|
16294
|
+
});
|
|
16295
|
+
this._resizeObserver.observe(container);
|
|
16296
|
+
}
|
|
16297
|
+
};
|
|
16298
|
+
LeafletMapAdapter.prototype._stopWatchSizeChangeToUpdateMinZoom = function () {
|
|
16299
|
+
var map = this.map;
|
|
16300
|
+
if (map) {
|
|
16301
|
+
map.setMinZoom(0);
|
|
16302
|
+
}
|
|
16303
|
+
if (this._resizeObserver) {
|
|
16304
|
+
this._resizeObserver.disconnect();
|
|
16305
|
+
this._resizeObserver = undefined;
|
|
16306
|
+
}
|
|
16307
|
+
};
|
|
16308
|
+
LeafletMapAdapter.prototype._addMapListeners = function () {
|
|
16309
|
+
var _this = this;
|
|
16310
|
+
var map = this.map;
|
|
16311
|
+
if (map) {
|
|
16312
|
+
map.on('click', function (evt) {
|
|
16313
|
+
_this.onMapClick(evt);
|
|
16314
|
+
});
|
|
16315
|
+
var _loop_1 = function (e) {
|
|
16316
|
+
map.on(e, function () { return _this.emitter.emit(e, _this); }, map);
|
|
16317
|
+
};
|
|
16318
|
+
for (var _i = 0, _a = this._universalEvents; _i < _a.length; _i++) {
|
|
16319
|
+
var e = _a[_i];
|
|
16320
|
+
_loop_1(e);
|
|
16321
|
+
}
|
|
16322
|
+
var _loop_2 = function (e) {
|
|
16323
|
+
map.on(e, function (evt) {
|
|
16324
|
+
return _this.emitter.emit(e, convertMapClickEvent(evt));
|
|
16325
|
+
}, map);
|
|
16326
|
+
};
|
|
16327
|
+
for (var _b = 0, _c = this._positionEvents; _b < _c.length; _b++) {
|
|
16328
|
+
var e = _c[_b];
|
|
16329
|
+
_loop_2(e);
|
|
16330
|
+
}
|
|
16331
|
+
}
|
|
16332
|
+
};
|
|
16333
|
+
LeafletMapAdapter.layerAdapters = {
|
|
16334
|
+
GEOJSON: GeoJsonAdapter,
|
|
16335
|
+
IMAGE: ImageAdapter,
|
|
16336
|
+
TILE: TileAdapter,
|
|
16337
|
+
WMS: WmsAdapter,
|
|
16338
|
+
// // MVT: MvtAdapter,
|
|
16339
|
+
OSM: OsmAdapter,
|
|
16340
|
+
};
|
|
16341
|
+
LeafletMapAdapter.controlAdapters = {
|
|
16342
|
+
ZOOM: leafletSrc.exports.Control.Zoom,
|
|
16343
|
+
ATTRIBUTION: AttributionControl,
|
|
16344
|
+
};
|
|
16345
|
+
LeafletMapAdapter.Map = leafletSrc.exports.Map;
|
|
16346
|
+
return LeafletMapAdapter;
|
|
16341
16347
|
}());
|
|
16342
16348
|
|
|
16343
|
-
/**
|
|
16344
|
-
* @module leaflet-map-adapter
|
|
16345
|
-
*/
|
|
16349
|
+
/**
|
|
16350
|
+
* @module leaflet-map-adapter
|
|
16351
|
+
*/
|
|
16346
16352
|
var LeafletMapAdapter = LeafletMapAdapter$1;
|
|
16347
16353
|
|
|
16348
16354
|
return LeafletMapAdapter;
|