@nextgis/leaflet-map-adapter 1.8.4 → 1.9.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 -1
- package/lib/leaflet-map-adapter.esm-browser.js +72 -28
- 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 +72 -28
- 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 +68 -24
- package/lib/leaflet-map-adapter.global.js.map +1 -1
- package/lib/leaflet-map-adapter.global.prod.js +2 -2
- package/lib/leaflet-map-adapter.global.prod.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 1.9.0; author: NextGIS */
|
|
2
2
|
var LeafletMapAdapter = (function () {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -15193,7 +15193,7 @@ var LeafletMapAdapter = (function () {
|
|
|
15193
15193
|
}
|
|
15194
15194
|
}
|
|
15195
15195
|
};
|
|
15196
|
-
GeoJsonAdapter.prototype._openPopup = function (def, options, type,
|
|
15196
|
+
GeoJsonAdapter.prototype._openPopup = function (def, options, type, latLng) {
|
|
15197
15197
|
var _a, _b;
|
|
15198
15198
|
if (options === void 0) { options = {}; }
|
|
15199
15199
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -15245,7 +15245,7 @@ var LeafletMapAdapter = (function () {
|
|
|
15245
15245
|
}, this);
|
|
15246
15246
|
}
|
|
15247
15247
|
this._openedPopup.push([popup, _closeHandlers, def]);
|
|
15248
|
-
popup.openPopup(
|
|
15248
|
+
popup.openPopup(latLng);
|
|
15249
15249
|
}
|
|
15250
15250
|
return [2 /*return*/];
|
|
15251
15251
|
}
|
|
@@ -15393,7 +15393,7 @@ var LeafletMapAdapter = (function () {
|
|
|
15393
15393
|
ok = this._filterFun(def_1);
|
|
15394
15394
|
}
|
|
15395
15395
|
if (ok) {
|
|
15396
|
-
var _a = this.options,
|
|
15396
|
+
var _a = this.options, popup_1 = _a.popup, popupOptions_1 = _a.popupOptions, selectable = _a.selectable, interactive = _a.interactive, selectOnHover = _a.selectOnHover;
|
|
15397
15397
|
// @ts-ignore
|
|
15398
15398
|
layer.options.interactive = defined(interactive) ? interactive : true;
|
|
15399
15399
|
layer_.addLayer(layer);
|
|
@@ -15411,10 +15411,14 @@ var LeafletMapAdapter = (function () {
|
|
|
15411
15411
|
}
|
|
15412
15412
|
}
|
|
15413
15413
|
this._handleMouseEvents(layer);
|
|
15414
|
-
|
|
15415
|
-
|
|
15416
|
-
|
|
15417
|
-
|
|
15414
|
+
// The timeout is needed to display the popup immediately when adding a layer to the map.
|
|
15415
|
+
// Without a timeout, the layer may not yet have a _map object
|
|
15416
|
+
setTimeout(function () {
|
|
15417
|
+
if (popup_1) {
|
|
15418
|
+
_this._openPopup(__assign({ target: _this, layer: layer, feature: feature }, createFeaturePositionOptions(feature)), popupOptions_1, 'api');
|
|
15419
|
+
}
|
|
15420
|
+
_this._updateTooltip({ layer: layer, feature: feature });
|
|
15421
|
+
});
|
|
15418
15422
|
}
|
|
15419
15423
|
}
|
|
15420
15424
|
};
|
|
@@ -15992,6 +15996,15 @@ var LeafletMapAdapter = (function () {
|
|
|
15992
15996
|
return OsmAdapter;
|
|
15993
15997
|
}(TileAdapter));
|
|
15994
15998
|
|
|
15999
|
+
function arrayToBoundsExpression(bounds) {
|
|
16000
|
+
var e = bounds;
|
|
16001
|
+
// top, left, bottom, right
|
|
16002
|
+
return [
|
|
16003
|
+
[e[3], e[0]],
|
|
16004
|
+
[e[1], e[2]],
|
|
16005
|
+
];
|
|
16006
|
+
}
|
|
16007
|
+
|
|
15995
16008
|
var LeafletMapAdapter$1 = /** @class */ (function () {
|
|
15996
16009
|
function LeafletMapAdapter() {
|
|
15997
16010
|
this.options = { target: 'map' };
|
|
@@ -16013,10 +16026,7 @@ var LeafletMapAdapter = (function () {
|
|
|
16013
16026
|
this.options = __assign({}, options);
|
|
16014
16027
|
if (this.options.target) {
|
|
16015
16028
|
var _a = this.options, zoom = _a.zoom, center = _a.center, maxZoom = _a.maxZoom, minZoom = _a.minZoom, mb = _a.maxBounds, mapAdapterOptions = _a.mapAdapterOptions;
|
|
16016
|
-
this.map = new leafletSrc.exports.Map(this.options.target, __assign({ attributionControl: false, zoomControl: false, maxBounds: mb && [
|
|
16017
|
-
[mb[1], mb[0]],
|
|
16018
|
-
[mb[3], mb[2]],
|
|
16019
|
-
], maxZoom: maxZoom, minZoom: minZoom, center: center && [center[1], center[0]], zoom: zoom }, mapAdapterOptions));
|
|
16029
|
+
this.map = 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));
|
|
16020
16030
|
// create default pane
|
|
16021
16031
|
var defPane = this.map.createPane('order-0');
|
|
16022
16032
|
this.map._addUnselectCb = function (def) {
|
|
@@ -16047,14 +16057,52 @@ var LeafletMapAdapter = (function () {
|
|
|
16047
16057
|
this.map.getContainer().style.cursor = cursor;
|
|
16048
16058
|
}
|
|
16049
16059
|
};
|
|
16050
|
-
LeafletMapAdapter.prototype.setView = function (
|
|
16051
|
-
var
|
|
16052
|
-
if (
|
|
16053
|
-
|
|
16054
|
-
|
|
16060
|
+
LeafletMapAdapter.prototype.setView = function (lngLatOrOpt, zoom) {
|
|
16061
|
+
var map = this.map;
|
|
16062
|
+
if (!map)
|
|
16063
|
+
return;
|
|
16064
|
+
if (Array.isArray(lngLatOrOpt)) {
|
|
16065
|
+
var lngLat = lngLatOrOpt;
|
|
16066
|
+
var lng = lngLat[0], lat = lngLat[1];
|
|
16067
|
+
if (this.map) {
|
|
16068
|
+
if (typeof zoom === 'number') {
|
|
16069
|
+
this.map.setView([lat, lng], zoom, { animate: false });
|
|
16070
|
+
}
|
|
16071
|
+
else {
|
|
16072
|
+
this.setCenter([lng, lat]);
|
|
16073
|
+
}
|
|
16074
|
+
}
|
|
16075
|
+
}
|
|
16076
|
+
else {
|
|
16077
|
+
var zoom_1 = lngLatOrOpt.zoom, center = lngLatOrOpt.center, maxBounds = lngLatOrOpt.maxBounds, bounds = lngLatOrOpt.bounds, minZoom = lngLatOrOpt.minZoom, maxZoom = lngLatOrOpt.maxZoom;
|
|
16078
|
+
if (center && zoom_1 !== undefined) {
|
|
16079
|
+
this.setView(center, zoom_1);
|
|
16055
16080
|
}
|
|
16056
16081
|
else {
|
|
16057
|
-
|
|
16082
|
+
if (zoom_1 !== undefined) {
|
|
16083
|
+
this.setZoom(zoom_1);
|
|
16084
|
+
}
|
|
16085
|
+
if (center) {
|
|
16086
|
+
this.setCenter(center);
|
|
16087
|
+
}
|
|
16088
|
+
}
|
|
16089
|
+
if (bounds) {
|
|
16090
|
+
this.fitBounds(bounds);
|
|
16091
|
+
}
|
|
16092
|
+
if (maxBounds !== undefined) {
|
|
16093
|
+
if (maxBounds) {
|
|
16094
|
+
map.setMaxBounds(arrayToBoundsExpression(maxBounds));
|
|
16095
|
+
}
|
|
16096
|
+
else {
|
|
16097
|
+
// @ts-ignore `null` works for unset maxBounds, but not in typing
|
|
16098
|
+
map.setMaxBounds(null);
|
|
16099
|
+
}
|
|
16100
|
+
}
|
|
16101
|
+
if (maxZoom !== undefined) {
|
|
16102
|
+
map.setMaxZoom(maxZoom);
|
|
16103
|
+
}
|
|
16104
|
+
if (minZoom !== undefined) {
|
|
16105
|
+
map.setMinZoom(minZoom);
|
|
16058
16106
|
}
|
|
16059
16107
|
}
|
|
16060
16108
|
};
|
|
@@ -16089,7 +16137,7 @@ var LeafletMapAdapter = (function () {
|
|
|
16089
16137
|
return [sw.lng, sw.lat, ne.lng, ne.lat];
|
|
16090
16138
|
};
|
|
16091
16139
|
// [west, south, east, north]
|
|
16092
|
-
LeafletMapAdapter.prototype.fitBounds = function (
|
|
16140
|
+
LeafletMapAdapter.prototype.fitBounds = function (bounds, options) {
|
|
16093
16141
|
if (options === void 0) { options = {}; }
|
|
16094
16142
|
if (this.map) {
|
|
16095
16143
|
var maxZoom = options.maxZoom, offset = options.offset, padding = options.padding;
|
|
@@ -16103,11 +16151,7 @@ var LeafletMapAdapter = (function () {
|
|
|
16103
16151
|
if (offset) {
|
|
16104
16152
|
opt.padding = offset;
|
|
16105
16153
|
}
|
|
16106
|
-
|
|
16107
|
-
this.map.fitBounds([
|
|
16108
|
-
[e[3], e[0]],
|
|
16109
|
-
[e[1], e[2]],
|
|
16110
|
-
], opt);
|
|
16154
|
+
this.map.fitBounds(arrayToBoundsExpression(bounds), opt);
|
|
16111
16155
|
}
|
|
16112
16156
|
};
|
|
16113
16157
|
LeafletMapAdapter.prototype.getLayerAdapter = function (name) {
|