@nextgis/leaflet-map-adapter 3.0.0-alpha.0 → 3.0.0-alpha.12
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/index.d.ts +0 -1
- package/lib/leaflet-map-adapter.esm-browser.js +86 -33
- package/lib/leaflet-map-adapter.esm-browser.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.js +71 -33
- package/lib/leaflet-map-adapter.esm-bundler.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.prod.js +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.global.js +86 -33
- package/lib/leaflet-map-adapter.global.js.map +1 -1
- package/lib/leaflet-map-adapter.global.prod.js +1 -1
- package/lib/leaflet-map-adapter.global.prod.js.map +1 -1
- package/package.json +10 -10
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { EventEmitter } from 'events';
|
|
3
2
|
import { Control, ControlOptions, Map, Layer, GridLayer, LeafletMouseEvent } from 'leaflet';
|
|
4
3
|
import { AttributionControlOptions, MapAdapter, LayerAdapter, MapOptions, ViewOptions, FitOptions, MapControl, CreateControlOptions, ButtonControlOptions, LocateOptions, LocationEvents, Locate } from '@nextgis/webmap';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 3.0.0-alpha.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 3.0.0-alpha.5; author: NextGIS */
|
|
2
2
|
var domain;
|
|
3
3
|
|
|
4
4
|
// This constructor is used to store event handlers. Instantiating this is
|
|
@@ -29,7 +29,7 @@ EventEmitter.init = function() {
|
|
|
29
29
|
this.domain = null;
|
|
30
30
|
if (EventEmitter.usingDomains) {
|
|
31
31
|
// if there is an active domain, then attach to it.
|
|
32
|
-
if (domain.active
|
|
32
|
+
if (domain.active) ;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
|
|
@@ -14653,6 +14653,21 @@ function debounce(cb, wait = 10) {
|
|
|
14653
14653
|
return wrapper;
|
|
14654
14654
|
}
|
|
14655
14655
|
|
|
14656
|
+
function updateUrlParams(urlStr, params) {
|
|
14657
|
+
const url = new URL(urlStr);
|
|
14658
|
+
const searchParams = new URLSearchParams(url.search);
|
|
14659
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
14660
|
+
if (value === void 0) {
|
|
14661
|
+
searchParams.delete(key);
|
|
14662
|
+
} else {
|
|
14663
|
+
searchParams.set(key, value);
|
|
14664
|
+
}
|
|
14665
|
+
});
|
|
14666
|
+
searchParams.set("timestamp", String((/* @__PURE__ */ new Date()).getTime()));
|
|
14667
|
+
const newSearch = [...searchParams.entries()].map(([key, value]) => `${key}=${value}`).join("&");
|
|
14668
|
+
return `${url.origin}${url.pathname}?${newSearch}`;
|
|
14669
|
+
}
|
|
14670
|
+
|
|
14656
14671
|
function boundsToArray(bounds) {
|
|
14657
14672
|
const ne = bounds.getNorthEast();
|
|
14658
14673
|
const sw = bounds.getSouthWest();
|
|
@@ -14918,8 +14933,8 @@ function isPaintCallback(paint) {
|
|
|
14918
14933
|
}
|
|
14919
14934
|
|
|
14920
14935
|
var __defProp$9 = Object.defineProperty;
|
|
14921
|
-
var __defProps$
|
|
14922
|
-
var __getOwnPropDescs$
|
|
14936
|
+
var __defProps$5 = Object.defineProperties;
|
|
14937
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
14923
14938
|
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
14924
14939
|
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
14925
14940
|
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
@@ -14935,7 +14950,7 @@ var __spreadValues$6 = (a, b) => {
|
|
|
14935
14950
|
}
|
|
14936
14951
|
return a;
|
|
14937
14952
|
};
|
|
14938
|
-
var __spreadProps$
|
|
14953
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
14939
14954
|
var __objRest$2 = (source, exclude) => {
|
|
14940
14955
|
var target = {};
|
|
14941
14956
|
for (var prop in source)
|
|
@@ -15030,7 +15045,7 @@ class GeoJsonPaint {
|
|
|
15030
15045
|
if (html) {
|
|
15031
15046
|
element.innerHTML = html;
|
|
15032
15047
|
}
|
|
15033
|
-
const divIcon = new leafletSrcExports.DivIcon(__spreadProps$
|
|
15048
|
+
const divIcon = new leafletSrcExports.DivIcon(__spreadProps$5(__spreadValues$6({
|
|
15034
15049
|
className: ""
|
|
15035
15050
|
}, toLIconOpt), {
|
|
15036
15051
|
html: element
|
|
@@ -15079,8 +15094,8 @@ class GeoJsonPaint {
|
|
|
15079
15094
|
}
|
|
15080
15095
|
|
|
15081
15096
|
var __defProp$8 = Object.defineProperty;
|
|
15082
|
-
var __defProps$
|
|
15083
|
-
var __getOwnPropDescs$
|
|
15097
|
+
var __defProps$4 = Object.defineProperties;
|
|
15098
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
15084
15099
|
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
15085
15100
|
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
15086
15101
|
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
@@ -15096,7 +15111,7 @@ var __spreadValues$5 = (a, b) => {
|
|
|
15096
15111
|
}
|
|
15097
15112
|
return a;
|
|
15098
15113
|
};
|
|
15099
|
-
var __spreadProps$
|
|
15114
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
15100
15115
|
var __publicField$5 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15101
15116
|
var __async = (__this, __arguments, generator) => {
|
|
15102
15117
|
return new Promise((resolve, reject) => {
|
|
@@ -15145,7 +15160,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15145
15160
|
addLayer(options) {
|
|
15146
15161
|
Object.assign(this.options, options);
|
|
15147
15162
|
this.paint = options.paint;
|
|
15148
|
-
this.layer = new leafletSrcExports.FeatureGroup([], __spreadProps$
|
|
15163
|
+
this.layer = new leafletSrcExports.FeatureGroup([], __spreadProps$4(__spreadValues$5({}, options.nativeOptions), {
|
|
15149
15164
|
pane: this.pane
|
|
15150
15165
|
}));
|
|
15151
15166
|
this.selectedPaint = options.selectedPaint;
|
|
@@ -15495,7 +15510,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15495
15510
|
if (feature) {
|
|
15496
15511
|
return this._paint.preparePaint(__spreadValues$5(__spreadValues$5({}, PAINT), paint(feature)));
|
|
15497
15512
|
} else {
|
|
15498
|
-
return this._paint.preparePaint(__spreadProps$
|
|
15513
|
+
return this._paint.preparePaint(__spreadProps$4(__spreadValues$5({}, PAINT), { type: "path" }));
|
|
15499
15514
|
}
|
|
15500
15515
|
}
|
|
15501
15516
|
};
|
|
@@ -15655,7 +15670,11 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15655
15670
|
}
|
|
15656
15671
|
}
|
|
15657
15672
|
|
|
15658
|
-
function callAjax(
|
|
15673
|
+
function callAjax({
|
|
15674
|
+
src,
|
|
15675
|
+
headers,
|
|
15676
|
+
withCredentials
|
|
15677
|
+
}) {
|
|
15659
15678
|
let abortFunc = () => {
|
|
15660
15679
|
};
|
|
15661
15680
|
const promise = new Promise((resolve, reject) => {
|
|
@@ -15665,6 +15684,9 @@ function callAjax(src, headers) {
|
|
|
15665
15684
|
for (const h in headers) {
|
|
15666
15685
|
xhr.setRequestHeader(h, headers[h]);
|
|
15667
15686
|
}
|
|
15687
|
+
if (withCredentials) {
|
|
15688
|
+
xhr.withCredentials = withCredentials;
|
|
15689
|
+
}
|
|
15668
15690
|
xhr.onload = function() {
|
|
15669
15691
|
const arrayBufferView = new Uint8Array(this.response);
|
|
15670
15692
|
const blob = new Blob([arrayBufferView], { type: "image/png" });
|
|
@@ -15787,12 +15809,16 @@ class ImageOverlay extends leafletSrcExports.ImageOverlay {
|
|
|
15787
15809
|
}
|
|
15788
15810
|
_initImage() {
|
|
15789
15811
|
super._initImage();
|
|
15790
|
-
const headers = this.options
|
|
15812
|
+
const { headers, withCredentials } = this.options;
|
|
15791
15813
|
const img = this._image;
|
|
15792
15814
|
const src = img.src;
|
|
15793
15815
|
img.src = "";
|
|
15794
15816
|
imageQueue.add(() => {
|
|
15795
|
-
const [promise, abortFunc] = callAjax(
|
|
15817
|
+
const [promise, abortFunc] = callAjax({
|
|
15818
|
+
src,
|
|
15819
|
+
headers,
|
|
15820
|
+
withCredentials
|
|
15821
|
+
});
|
|
15796
15822
|
promise.then((imgUrl) => {
|
|
15797
15823
|
img.src = imgUrl;
|
|
15798
15824
|
});
|
|
@@ -15807,6 +15833,7 @@ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key,
|
|
|
15807
15833
|
var __publicField$2 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15808
15834
|
class ImageLayer extends leafletSrcExports.Layer {
|
|
15809
15835
|
constructor(url, options) {
|
|
15836
|
+
var _a;
|
|
15810
15837
|
super(options);
|
|
15811
15838
|
__publicField$2(this, "defaultWmsParams", {
|
|
15812
15839
|
service: "WMS",
|
|
@@ -15824,8 +15851,10 @@ class ImageLayer extends leafletSrcExports.Layer {
|
|
|
15824
15851
|
opacity: 1,
|
|
15825
15852
|
isBack: false,
|
|
15826
15853
|
minZoom: 0,
|
|
15854
|
+
maxZoom: void 0,
|
|
15827
15855
|
pane: "tilePane",
|
|
15828
15856
|
headers: null,
|
|
15857
|
+
withCredentials: false,
|
|
15829
15858
|
viewPortBuffer: 0,
|
|
15830
15859
|
setViewDelay: 100
|
|
15831
15860
|
});
|
|
@@ -15846,7 +15875,11 @@ class ImageLayer extends leafletSrcExports.Layer {
|
|
|
15846
15875
|
}
|
|
15847
15876
|
}
|
|
15848
15877
|
leafletSrcExports.Util.setOptions(this, opts);
|
|
15849
|
-
this.wmsParams = leafletSrcExports.Util.extend(
|
|
15878
|
+
this.wmsParams = leafletSrcExports.Util.extend(
|
|
15879
|
+
{},
|
|
15880
|
+
this.defaultWmsParams,
|
|
15881
|
+
(_a = params == null ? void 0 : params.params) != null ? _a : {}
|
|
15882
|
+
);
|
|
15850
15883
|
}
|
|
15851
15884
|
setParams(params) {
|
|
15852
15885
|
leafletSrcExports.Util.extend(this.wmsParams, params);
|
|
@@ -15895,7 +15928,8 @@ class ImageLayer extends leafletSrcExports.Layer {
|
|
|
15895
15928
|
const overlay = new ImageOverlay(url, bounds, {
|
|
15896
15929
|
opacity: 0,
|
|
15897
15930
|
pane: this.options.pane,
|
|
15898
|
-
headers: this.options.headers
|
|
15931
|
+
headers: this.options.headers,
|
|
15932
|
+
withCredentials: this.options.withCredentials
|
|
15899
15933
|
});
|
|
15900
15934
|
overlay.addTo(this._map);
|
|
15901
15935
|
this._loadedOverlay = overlay;
|
|
@@ -15993,6 +16027,8 @@ class ImageLayer extends leafletSrcExports.Layer {
|
|
|
15993
16027
|
}
|
|
15994
16028
|
|
|
15995
16029
|
var __defProp$4 = Object.defineProperty;
|
|
16030
|
+
var __defProps$3 = Object.defineProperties;
|
|
16031
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
15996
16032
|
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
15997
16033
|
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
15998
16034
|
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
@@ -16008,6 +16044,7 @@ var __spreadValues$4 = (a, b) => {
|
|
|
16008
16044
|
}
|
|
16009
16045
|
return a;
|
|
16010
16046
|
};
|
|
16047
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
16011
16048
|
var __publicField$1 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
16012
16049
|
class ImageAdapter extends BaseAdapter {
|
|
16013
16050
|
constructor() {
|
|
@@ -16015,15 +16052,21 @@ class ImageAdapter extends BaseAdapter {
|
|
|
16015
16052
|
__publicField$1(this, "layer");
|
|
16016
16053
|
}
|
|
16017
16054
|
addLayer(options) {
|
|
16055
|
+
var _a;
|
|
16018
16056
|
const url = options && options.url;
|
|
16019
16057
|
if (url) {
|
|
16020
|
-
options = __spreadValues$4({ transparent: true }, options);
|
|
16021
16058
|
const updateWmsParamsFromOpt = options.updateWmsParams;
|
|
16022
|
-
this.layer = new ImageLayer(url, __spreadValues$4(__spreadValues$4(__spreadValues$4({
|
|
16059
|
+
this.layer = new ImageLayer(url, __spreadProps$3(__spreadValues$4(__spreadValues$4(__spreadValues$4({
|
|
16023
16060
|
pane: this.pane,
|
|
16024
16061
|
headers: options.headers,
|
|
16025
16062
|
setViewDelay: options.setViewDelay
|
|
16026
|
-
},
|
|
16063
|
+
}, __spreadProps$3(__spreadValues$4({
|
|
16064
|
+
transparent: true
|
|
16065
|
+
}, options), {
|
|
16066
|
+
opacity: (_a = options.opacity) != null ? _a : void 0
|
|
16067
|
+
})), options.params), options.nativeOptions), {
|
|
16068
|
+
maxZoom: 12
|
|
16069
|
+
}));
|
|
16027
16070
|
if (updateWmsParamsFromOpt) {
|
|
16028
16071
|
const updateWmsParams = this.layer.updateWmsParams;
|
|
16029
16072
|
this.layer.updateWmsParams = function(map) {
|
|
@@ -16034,6 +16077,13 @@ class ImageAdapter extends BaseAdapter {
|
|
|
16034
16077
|
return this.layer;
|
|
16035
16078
|
}
|
|
16036
16079
|
}
|
|
16080
|
+
updateLayer(options) {
|
|
16081
|
+
if (this.layer) {
|
|
16082
|
+
const params = (options == null ? void 0 : options.params) || {};
|
|
16083
|
+
leafletSrcExports.Util.extend(this.layer.wmsParams, params);
|
|
16084
|
+
this.layer.update();
|
|
16085
|
+
}
|
|
16086
|
+
}
|
|
16037
16087
|
}
|
|
16038
16088
|
__publicField$1(ImageAdapter, "queue", imageQueue);
|
|
16039
16089
|
|
|
@@ -16048,13 +16098,13 @@ function makeRemote(Base) {
|
|
|
16048
16098
|
}
|
|
16049
16099
|
}
|
|
16050
16100
|
createTile(coords, done) {
|
|
16051
|
-
const
|
|
16101
|
+
const src = this.getTileUrl(coords);
|
|
16052
16102
|
const tile = document.createElement("img");
|
|
16053
|
-
const [promise, abortFunc] = callAjax(
|
|
16054
|
-
|
|
16055
|
-
|
|
16056
|
-
this.options.headers
|
|
16057
|
-
);
|
|
16103
|
+
const [promise, abortFunc] = callAjax({
|
|
16104
|
+
src,
|
|
16105
|
+
withCredentials: this.options.withCredentials,
|
|
16106
|
+
headers: this.options.headers
|
|
16107
|
+
});
|
|
16058
16108
|
promise.then((response) => {
|
|
16059
16109
|
tile.src = response;
|
|
16060
16110
|
done(null, tile);
|
|
@@ -16144,9 +16194,10 @@ class TileAdapter extends BaseAdapter {
|
|
|
16144
16194
|
tileLayerOptions.subdomains = opt.subdomains;
|
|
16145
16195
|
}
|
|
16146
16196
|
let layer;
|
|
16147
|
-
if (opt.headers) {
|
|
16197
|
+
if (opt.headers || opt.withCredentials) {
|
|
16148
16198
|
layer = new TileLayer(url, __spreadProps$2(__spreadValues$3({}, tileLayerOptions), {
|
|
16149
16199
|
headers: opt.headers,
|
|
16200
|
+
withCredentials: opt.withCredentials,
|
|
16150
16201
|
setViewDelay: opt.setViewDelay
|
|
16151
16202
|
}));
|
|
16152
16203
|
} else {
|
|
@@ -16156,13 +16207,12 @@ class TileAdapter extends BaseAdapter {
|
|
|
16156
16207
|
}
|
|
16157
16208
|
}
|
|
16158
16209
|
}
|
|
16159
|
-
updateLayer() {
|
|
16210
|
+
updateLayer(options) {
|
|
16160
16211
|
if (this.layer) {
|
|
16161
16212
|
const currentUrl = this.layer._url;
|
|
16162
|
-
|
|
16163
|
-
|
|
16164
|
-
|
|
16165
|
-
this.layer.setUrl(newUrl);
|
|
16213
|
+
if (options == null ? void 0 : options.params) {
|
|
16214
|
+
this.layer.setUrl(updateUrlParams(currentUrl, options.params));
|
|
16215
|
+
}
|
|
16166
16216
|
this.layer.redraw();
|
|
16167
16217
|
}
|
|
16168
16218
|
}
|
|
@@ -16252,8 +16302,11 @@ class WmsAdapter extends BaseAdapter {
|
|
|
16252
16302
|
transparent: true
|
|
16253
16303
|
}, options.nativeOptions);
|
|
16254
16304
|
let layer;
|
|
16255
|
-
if (opt.headers) {
|
|
16256
|
-
layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), {
|
|
16305
|
+
if (opt.headers || opt.withCredentials) {
|
|
16306
|
+
layer = new WmsLayer(url, __spreadProps(__spreadValues$1({}, layerOptions), {
|
|
16307
|
+
headers: opt.headers,
|
|
16308
|
+
withCredentials: opt.withCredentials
|
|
16309
|
+
}));
|
|
16257
16310
|
} else {
|
|
16258
16311
|
layer = new leafletSrcExports.TileLayer.WMS(url, layerOptions);
|
|
16259
16312
|
}
|