@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
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { Control, DomEvent, GeoJSON, FeatureGroup, DivIcon, Marker, CircleMarker, ImageOverlay as ImageOverlay$1, Layer, Util, CRS, GridLayer, DomUtil, TileLayer as TileLayer$1, Map } from 'leaflet';
|
|
4
4
|
import { debounce as debounce$1, defined } from '@nextgis/utils';
|
|
@@ -499,7 +499,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
|
-
async _openPopup(def, options = {}, type,
|
|
502
|
+
async _openPopup(def, options = {}, type, latLng) {
|
|
503
503
|
var _a, _b;
|
|
504
504
|
const { feature, layer } = def;
|
|
505
505
|
const { minWidth, autoPan, maxWidth, closeButton: closeButton_, } = { minWidth: 300, ...options };
|
|
@@ -551,7 +551,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
551
551
|
}, this);
|
|
552
552
|
}
|
|
553
553
|
this._openedPopup.push([popup, _closeHandlers, def]);
|
|
554
|
-
popup.openPopup(
|
|
554
|
+
popup.openPopup(latLng);
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
557
|
_removePopup(popup) {
|
|
@@ -713,15 +713,19 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
715
|
this._handleMouseEvents(layer);
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
716
|
+
// The timeout is needed to display the popup immediately when adding a layer to the map.
|
|
717
|
+
// Without a timeout, the layer may not yet have a _map object
|
|
718
|
+
setTimeout(() => {
|
|
719
|
+
if (popup) {
|
|
720
|
+
this._openPopup({
|
|
721
|
+
target: this,
|
|
722
|
+
layer,
|
|
723
|
+
feature,
|
|
724
|
+
...createFeaturePositionOptions(feature),
|
|
725
|
+
}, popupOptions, 'api');
|
|
726
|
+
}
|
|
727
|
+
this._updateTooltip({ layer, feature });
|
|
728
|
+
});
|
|
725
729
|
}
|
|
726
730
|
}
|
|
727
731
|
}
|
|
@@ -1316,6 +1320,15 @@ class OsmAdapter extends TileAdapter {
|
|
|
1316
1320
|
}
|
|
1317
1321
|
}
|
|
1318
1322
|
|
|
1323
|
+
function arrayToBoundsExpression(bounds) {
|
|
1324
|
+
const e = bounds;
|
|
1325
|
+
// top, left, bottom, right
|
|
1326
|
+
return [
|
|
1327
|
+
[e[3], e[0]],
|
|
1328
|
+
[e[1], e[2]],
|
|
1329
|
+
];
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1319
1332
|
class LeafletMapAdapter$1 {
|
|
1320
1333
|
constructor() {
|
|
1321
1334
|
this.options = { target: 'map' };
|
|
@@ -1339,10 +1352,7 @@ class LeafletMapAdapter$1 {
|
|
|
1339
1352
|
this.map = new Map(this.options.target, {
|
|
1340
1353
|
attributionControl: false,
|
|
1341
1354
|
zoomControl: false,
|
|
1342
|
-
maxBounds: mb
|
|
1343
|
-
[mb[1], mb[0]],
|
|
1344
|
-
[mb[3], mb[2]],
|
|
1345
|
-
],
|
|
1355
|
+
maxBounds: mb ? arrayToBoundsExpression(mb) : undefined,
|
|
1346
1356
|
maxZoom,
|
|
1347
1357
|
minZoom,
|
|
1348
1358
|
center: center && [center[1], center[0]],
|
|
@@ -1379,14 +1389,52 @@ class LeafletMapAdapter$1 {
|
|
|
1379
1389
|
this.map.getContainer().style.cursor = cursor;
|
|
1380
1390
|
}
|
|
1381
1391
|
}
|
|
1382
|
-
setView(
|
|
1383
|
-
const
|
|
1384
|
-
if (
|
|
1385
|
-
|
|
1386
|
-
|
|
1392
|
+
setView(lngLatOrOpt, zoom) {
|
|
1393
|
+
const map = this.map;
|
|
1394
|
+
if (!map)
|
|
1395
|
+
return;
|
|
1396
|
+
if (Array.isArray(lngLatOrOpt)) {
|
|
1397
|
+
const lngLat = lngLatOrOpt;
|
|
1398
|
+
const [lng, lat] = lngLat;
|
|
1399
|
+
if (this.map) {
|
|
1400
|
+
if (typeof zoom === 'number') {
|
|
1401
|
+
this.map.setView([lat, lng], zoom, { animate: false });
|
|
1402
|
+
}
|
|
1403
|
+
else {
|
|
1404
|
+
this.setCenter([lng, lat]);
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
else {
|
|
1409
|
+
const { zoom, center, maxBounds, bounds, minZoom, maxZoom } = lngLatOrOpt;
|
|
1410
|
+
if (center && zoom !== undefined) {
|
|
1411
|
+
this.setView(center, zoom);
|
|
1387
1412
|
}
|
|
1388
1413
|
else {
|
|
1389
|
-
|
|
1414
|
+
if (zoom !== undefined) {
|
|
1415
|
+
this.setZoom(zoom);
|
|
1416
|
+
}
|
|
1417
|
+
if (center) {
|
|
1418
|
+
this.setCenter(center);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
if (bounds) {
|
|
1422
|
+
this.fitBounds(bounds);
|
|
1423
|
+
}
|
|
1424
|
+
if (maxBounds !== undefined) {
|
|
1425
|
+
if (maxBounds) {
|
|
1426
|
+
map.setMaxBounds(arrayToBoundsExpression(maxBounds));
|
|
1427
|
+
}
|
|
1428
|
+
else {
|
|
1429
|
+
// @ts-ignore `null` works for unset maxBounds, but not in typing
|
|
1430
|
+
map.setMaxBounds(null);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
if (maxZoom !== undefined) {
|
|
1434
|
+
map.setMaxZoom(maxZoom);
|
|
1435
|
+
}
|
|
1436
|
+
if (minZoom !== undefined) {
|
|
1437
|
+
map.setMinZoom(minZoom);
|
|
1390
1438
|
}
|
|
1391
1439
|
}
|
|
1392
1440
|
}
|
|
@@ -1421,7 +1469,7 @@ class LeafletMapAdapter$1 {
|
|
|
1421
1469
|
return [sw.lng, sw.lat, ne.lng, ne.lat];
|
|
1422
1470
|
}
|
|
1423
1471
|
// [west, south, east, north]
|
|
1424
|
-
fitBounds(
|
|
1472
|
+
fitBounds(bounds, options = {}) {
|
|
1425
1473
|
if (this.map) {
|
|
1426
1474
|
const { maxZoom, offset, padding } = options;
|
|
1427
1475
|
const opt = {};
|
|
@@ -1434,11 +1482,7 @@ class LeafletMapAdapter$1 {
|
|
|
1434
1482
|
if (offset) {
|
|
1435
1483
|
opt.padding = offset;
|
|
1436
1484
|
}
|
|
1437
|
-
|
|
1438
|
-
this.map.fitBounds([
|
|
1439
|
-
[e[3], e[0]],
|
|
1440
|
-
[e[1], e[2]],
|
|
1441
|
-
], opt);
|
|
1485
|
+
this.map.fitBounds(arrayToBoundsExpression(bounds), opt);
|
|
1442
1486
|
}
|
|
1443
1487
|
}
|
|
1444
1488
|
getLayerAdapter(name) {
|