@nextgis/leaflet-map-adapter 1.9.1 → 1.11.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/index.d.ts +3 -0
- package/lib/leaflet-map-adapter.esm-browser.js +42 -6
- package/lib/leaflet-map-adapter.esm-browser.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js +2 -2
- package/lib/leaflet-map-adapter.esm-browser.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.js +42 -6
- 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 +47 -10
- 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
package/lib/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ declare class LeafletMapAdapter implements MapAdapter<Map_2, any, Control> {
|
|
|
45
45
|
};
|
|
46
46
|
emitter: EventEmitter;
|
|
47
47
|
map?: Map_2;
|
|
48
|
+
private _resizeObserver?;
|
|
48
49
|
private _unselectCb;
|
|
49
50
|
private _universalEvents;
|
|
50
51
|
create(options: MapOptions): void;
|
|
@@ -75,6 +76,8 @@ declare class LeafletMapAdapter implements MapAdapter<Map_2, any, Control> {
|
|
|
75
76
|
onMapClick(evt: LeafletMouseEvent): void;
|
|
76
77
|
locate(opt: LocateOptions, events?: LocationEvents): Locate;
|
|
77
78
|
private _addUnselectCb;
|
|
79
|
+
private _watchSizeChangeToUpdateMinZoom;
|
|
80
|
+
private _stopWatchSizeChangeToUpdateMinZoom;
|
|
78
81
|
private _addMapListeners;
|
|
79
82
|
}
|
|
80
83
|
export default LeafletMapAdapter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 1.11.0; author: NextGIS */
|
|
2
2
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3
3
|
|
|
4
4
|
var events = {exports: {}};
|
|
@@ -14562,6 +14562,9 @@ function createControl(control, options = {}, map) {
|
|
|
14562
14562
|
if (options.bar) {
|
|
14563
14563
|
element.classList.add('leaflet-bar');
|
|
14564
14564
|
}
|
|
14565
|
+
if (options.addClass) {
|
|
14566
|
+
element.classList.add(options.addClass);
|
|
14567
|
+
}
|
|
14565
14568
|
if (!options.margin && !options.bar) {
|
|
14566
14569
|
element.style.marginBottom = '0px';
|
|
14567
14570
|
element.style.marginTop = '0px';
|
|
@@ -15090,7 +15093,10 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15090
15093
|
async _openPopup(def, options = {}, type, latLng) {
|
|
15091
15094
|
var _a, _b;
|
|
15092
15095
|
const { feature, layer } = def;
|
|
15093
|
-
const { minWidth, autoPan, maxWidth, closeButton: closeButton_, } = {
|
|
15096
|
+
const { minWidth, autoPan, maxWidth, closeButton: closeButton_, } = {
|
|
15097
|
+
minWidth: 300,
|
|
15098
|
+
...options,
|
|
15099
|
+
};
|
|
15094
15100
|
const closeButton = closeButton_ !== null && closeButton_ !== void 0 ? closeButton_ : !this.options.selectOnHover;
|
|
15095
15101
|
let popup;
|
|
15096
15102
|
const _closeHandlers = [];
|
|
@@ -15318,14 +15324,14 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15318
15324
|
}
|
|
15319
15325
|
}
|
|
15320
15326
|
_handleMouseEvents(layer) {
|
|
15321
|
-
const isSelected = (l) => this._selectedLayers.indexOf(l) !== -1;
|
|
15322
15327
|
const { onClick, onLayerClick, onMouseOut, onMouseOver } = this.options;
|
|
15323
15328
|
// TODO: remove backward compatibility for onLayerClick
|
|
15324
15329
|
const onClick_ = onClick || onLayerClick;
|
|
15325
15330
|
if (onClick_) {
|
|
15326
15331
|
layer.on('click', (e) => {
|
|
15332
|
+
const selected = !!this._getSelected(layer);
|
|
15327
15333
|
onClick_({
|
|
15328
|
-
selected
|
|
15334
|
+
selected,
|
|
15329
15335
|
...this._createMouseEvent(e),
|
|
15330
15336
|
});
|
|
15331
15337
|
}, this);
|
|
@@ -15347,6 +15353,9 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15347
15353
|
source: source,
|
|
15348
15354
|
});
|
|
15349
15355
|
}
|
|
15356
|
+
_getSelected(layer) {
|
|
15357
|
+
return this._selectedLayers.find((x) => x.layer === layer);
|
|
15358
|
+
}
|
|
15350
15359
|
_selectOnLayerClick(e) {
|
|
15351
15360
|
leafletSrc.exports.DomEvent.stopPropagation(e);
|
|
15352
15361
|
const layer = e.target;
|
|
@@ -15357,7 +15366,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
15357
15366
|
feature,
|
|
15358
15367
|
...createFeaturePositionOptions(feature),
|
|
15359
15368
|
};
|
|
15360
|
-
const isSelected = this.
|
|
15369
|
+
const isSelected = this._getSelected(layer);
|
|
15361
15370
|
if (isSelected) {
|
|
15362
15371
|
if (this.options && this.options.unselectOnSecondClick) {
|
|
15363
15372
|
this._unSelectLayer(isSelected);
|
|
@@ -15942,6 +15951,7 @@ class LeafletMapAdapter$1 {
|
|
|
15942
15951
|
if (this.map) {
|
|
15943
15952
|
this.map.remove();
|
|
15944
15953
|
}
|
|
15954
|
+
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
15945
15955
|
}
|
|
15946
15956
|
getContainer() {
|
|
15947
15957
|
return this.map && this.map.getContainer();
|
|
@@ -15992,17 +16002,22 @@ class LeafletMapAdapter$1 {
|
|
|
15992
16002
|
}
|
|
15993
16003
|
if (maxBounds !== undefined) {
|
|
15994
16004
|
if (maxBounds) {
|
|
15995
|
-
|
|
16005
|
+
const b = arrayToBoundsExpression(maxBounds);
|
|
16006
|
+
map.setMaxBounds(b);
|
|
16007
|
+
map.setMinZoom(map.getBoundsZoom(b));
|
|
16008
|
+
this._watchSizeChangeToUpdateMinZoom(b);
|
|
15996
16009
|
}
|
|
15997
16010
|
else {
|
|
15998
16011
|
// @ts-ignore `null` works for unset maxBounds, but not in typing
|
|
15999
16012
|
map.setMaxBounds(null);
|
|
16013
|
+
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
16000
16014
|
}
|
|
16001
16015
|
}
|
|
16002
16016
|
if (maxZoom !== undefined) {
|
|
16003
16017
|
map.setMaxZoom(maxZoom);
|
|
16004
16018
|
}
|
|
16005
16019
|
if (minZoom !== undefined) {
|
|
16020
|
+
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
16006
16021
|
map.setMinZoom(minZoom);
|
|
16007
16022
|
}
|
|
16008
16023
|
}
|
|
@@ -16137,6 +16152,27 @@ class LeafletMapAdapter$1 {
|
|
|
16137
16152
|
this._unselectCb.length = 0;
|
|
16138
16153
|
this._unselectCb.push(cb);
|
|
16139
16154
|
}
|
|
16155
|
+
_watchSizeChangeToUpdateMinZoom(bounds) {
|
|
16156
|
+
this._stopWatchSizeChangeToUpdateMinZoom();
|
|
16157
|
+
const container = this.getContainer();
|
|
16158
|
+
const map = this.map;
|
|
16159
|
+
if (container && map && window.ResizeObserver) {
|
|
16160
|
+
this._resizeObserver = new ResizeObserver(() => {
|
|
16161
|
+
map.setMinZoom(map.getBoundsZoom(bounds));
|
|
16162
|
+
});
|
|
16163
|
+
this._resizeObserver.observe(container);
|
|
16164
|
+
}
|
|
16165
|
+
}
|
|
16166
|
+
_stopWatchSizeChangeToUpdateMinZoom() {
|
|
16167
|
+
const map = this.map;
|
|
16168
|
+
if (map) {
|
|
16169
|
+
map.setMinZoom(0);
|
|
16170
|
+
}
|
|
16171
|
+
if (this._resizeObserver) {
|
|
16172
|
+
this._resizeObserver.disconnect();
|
|
16173
|
+
this._resizeObserver = undefined;
|
|
16174
|
+
}
|
|
16175
|
+
}
|
|
16140
16176
|
_addMapListeners() {
|
|
16141
16177
|
const map = this.map;
|
|
16142
16178
|
if (map) {
|