@nextgis/leaflet-map-adapter 1.18.21 → 1.19.1
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 +2 -2
- package/lib/leaflet-map-adapter.esm-browser.js +74 -74
- 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 +74 -74
- 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 +78 -78
- 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 +6 -6
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
|
-
import { AttributionControlOptions } from '@nextgis/webmap';
|
|
3
|
+
import type { AttributionControlOptions } from '@nextgis/webmap';
|
|
4
4
|
import type { ButtonControlOptions } from '@nextgis/webmap';
|
|
5
5
|
import { Control } from 'leaflet';
|
|
6
|
-
import { ControlOptions } from 'leaflet';
|
|
6
|
+
import type { ControlOptions } from 'leaflet';
|
|
7
7
|
import type { CreateControlOptions } from '@nextgis/webmap';
|
|
8
8
|
import { EventEmitter } from 'events';
|
|
9
9
|
import type { FitOptions } from '@nextgis/webmap';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/leaflet-map-adapter; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/leaflet-map-adapter; version: 1.19.1; 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: {}};
|
|
@@ -14541,16 +14541,22 @@ var leafletSrc = {exports: {}};
|
|
|
14541
14541
|
|
|
14542
14542
|
} (leafletSrc, leafletSrc.exports));
|
|
14543
14543
|
|
|
14544
|
-
|
|
14545
|
-
|
|
14546
|
-
|
|
14547
|
-
|
|
14548
|
-
|
|
14549
|
-
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
|
|
14544
|
+
class AttributionControl extends leafletSrc.exports.Control.Attribution {
|
|
14545
|
+
// options: AttributionControlOptions
|
|
14546
|
+
constructor(options) {
|
|
14547
|
+
super(options);
|
|
14548
|
+
const customAttribution = options && options.customAttribution;
|
|
14549
|
+
if (customAttribution) {
|
|
14550
|
+
let attributions = [];
|
|
14551
|
+
if (Array.isArray(customAttribution)) {
|
|
14552
|
+
attributions = customAttribution;
|
|
14553
|
+
}
|
|
14554
|
+
else if (customAttribution) {
|
|
14555
|
+
attributions = [customAttribution];
|
|
14556
|
+
}
|
|
14557
|
+
attributions.forEach((x) => this.addAttribution(x));
|
|
14558
|
+
}
|
|
14559
|
+
}
|
|
14554
14560
|
}
|
|
14555
14561
|
|
|
14556
14562
|
function createControl(control, options = {}, map) {
|
|
@@ -14625,24 +14631,6 @@ function createButtonControl(options, map) {
|
|
|
14625
14631
|
}, { bar: true }, map);
|
|
14626
14632
|
}
|
|
14627
14633
|
|
|
14628
|
-
class AttributionControl extends leafletSrc.exports.Control.Attribution {
|
|
14629
|
-
// options: AttributionControlOptions
|
|
14630
|
-
constructor(options) {
|
|
14631
|
-
super(options);
|
|
14632
|
-
const customAttribution = options && options.customAttribution;
|
|
14633
|
-
if (customAttribution) {
|
|
14634
|
-
let attributions = [];
|
|
14635
|
-
if (Array.isArray(customAttribution)) {
|
|
14636
|
-
attributions = customAttribution;
|
|
14637
|
-
}
|
|
14638
|
-
else if (customAttribution) {
|
|
14639
|
-
attributions = [customAttribution];
|
|
14640
|
-
}
|
|
14641
|
-
attributions.forEach((x) => this.addAttribution(x));
|
|
14642
|
-
}
|
|
14643
|
-
}
|
|
14644
|
-
}
|
|
14645
|
-
|
|
14646
14634
|
/**
|
|
14647
14635
|
* from https://github.com/CesiumGS/cesium/blob/master/Source/Core/defined.js
|
|
14648
14636
|
*
|
|
@@ -14687,6 +14675,39 @@ function boundsToArray(bounds) {
|
|
|
14687
14675
|
return [sw.lng, sw.lat, ne.lng, ne.lat];
|
|
14688
14676
|
}
|
|
14689
14677
|
|
|
14678
|
+
function findMostFrequentGeomType(arr) {
|
|
14679
|
+
const counts = {};
|
|
14680
|
+
for (let fry = 0; fry < arr.length; fry++) {
|
|
14681
|
+
counts[arr[fry]] = 1 + (counts[arr[fry]] || 0);
|
|
14682
|
+
}
|
|
14683
|
+
let maxName = '';
|
|
14684
|
+
for (const c in counts) {
|
|
14685
|
+
const maxCount = maxName ? counts[maxName] : 0;
|
|
14686
|
+
if (counts[c] > maxCount) {
|
|
14687
|
+
maxName = c;
|
|
14688
|
+
}
|
|
14689
|
+
}
|
|
14690
|
+
return maxName;
|
|
14691
|
+
}
|
|
14692
|
+
function detectType(geojson) {
|
|
14693
|
+
let geometry;
|
|
14694
|
+
if (geojson.type === 'FeatureCollection') {
|
|
14695
|
+
const featuresTypes = geojson.features.map((f) => f.geometry.type);
|
|
14696
|
+
geometry = findMostFrequentGeomType(featuresTypes);
|
|
14697
|
+
}
|
|
14698
|
+
else if (geojson.type === 'GeometryCollection') {
|
|
14699
|
+
const geometryTypes = geojson.geometries.map((g) => g.type);
|
|
14700
|
+
geometry = findMostFrequentGeomType(geometryTypes);
|
|
14701
|
+
}
|
|
14702
|
+
else if (geojson.type === 'Feature') {
|
|
14703
|
+
geometry = geojson.geometry.type;
|
|
14704
|
+
}
|
|
14705
|
+
else {
|
|
14706
|
+
geometry = geojson.type;
|
|
14707
|
+
}
|
|
14708
|
+
return geometry;
|
|
14709
|
+
}
|
|
14710
|
+
|
|
14690
14711
|
const typeAlias = {
|
|
14691
14712
|
Point: 'point',
|
|
14692
14713
|
LineString: 'line',
|
|
@@ -14748,39 +14769,6 @@ function createFeaturePositionOptions(features) {
|
|
|
14748
14769
|
};
|
|
14749
14770
|
}
|
|
14750
14771
|
|
|
14751
|
-
function findMostFrequentGeomType(arr) {
|
|
14752
|
-
const counts = {};
|
|
14753
|
-
for (let fry = 0; fry < arr.length; fry++) {
|
|
14754
|
-
counts[arr[fry]] = 1 + (counts[arr[fry]] || 0);
|
|
14755
|
-
}
|
|
14756
|
-
let maxName = '';
|
|
14757
|
-
for (const c in counts) {
|
|
14758
|
-
const maxCount = maxName ? counts[maxName] : 0;
|
|
14759
|
-
if (counts[c] > maxCount) {
|
|
14760
|
-
maxName = c;
|
|
14761
|
-
}
|
|
14762
|
-
}
|
|
14763
|
-
return maxName;
|
|
14764
|
-
}
|
|
14765
|
-
function detectType(geojson) {
|
|
14766
|
-
let geometry;
|
|
14767
|
-
if (geojson.type === 'FeatureCollection') {
|
|
14768
|
-
const featuresTypes = geojson.features.map((f) => f.geometry.type);
|
|
14769
|
-
geometry = findMostFrequentGeomType(featuresTypes);
|
|
14770
|
-
}
|
|
14771
|
-
else if (geojson.type === 'GeometryCollection') {
|
|
14772
|
-
const geometryTypes = geojson.geometries.map((g) => g.type);
|
|
14773
|
-
geometry = findMostFrequentGeomType(geometryTypes);
|
|
14774
|
-
}
|
|
14775
|
-
else if (geojson.type === 'Feature') {
|
|
14776
|
-
geometry = geojson.geometry.type;
|
|
14777
|
-
}
|
|
14778
|
-
else {
|
|
14779
|
-
geometry = geojson.type;
|
|
14780
|
-
}
|
|
14781
|
-
return geometry;
|
|
14782
|
-
}
|
|
14783
|
-
|
|
14784
14772
|
class BaseAdapter {
|
|
14785
14773
|
constructor(map, options) {
|
|
14786
14774
|
this.map = map;
|
|
@@ -14802,6 +14790,18 @@ class BaseAdapter {
|
|
|
14802
14790
|
}
|
|
14803
14791
|
}
|
|
14804
14792
|
|
|
14793
|
+
function convertMapClickEvent(evt) {
|
|
14794
|
+
const coord = evt.containerPoint;
|
|
14795
|
+
const latLng = evt.latlng;
|
|
14796
|
+
const { lat, lng } = latLng;
|
|
14797
|
+
return {
|
|
14798
|
+
latLng,
|
|
14799
|
+
lngLat: [lng, lat],
|
|
14800
|
+
pixel: { left: coord.x, top: coord.y },
|
|
14801
|
+
source: evt,
|
|
14802
|
+
};
|
|
14803
|
+
}
|
|
14804
|
+
|
|
14805
14805
|
function createMouseEvent({ layer, source, }) {
|
|
14806
14806
|
const layer_ = source.target;
|
|
14807
14807
|
const feature = layer_.feature;
|
|
@@ -15907,6 +15907,18 @@ class TileAdapter extends BaseAdapter {
|
|
|
15907
15907
|
}
|
|
15908
15908
|
}
|
|
15909
15909
|
|
|
15910
|
+
class OsmAdapter extends TileAdapter {
|
|
15911
|
+
addLayer(options) {
|
|
15912
|
+
const url = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
|
15913
|
+
return super.addLayer({
|
|
15914
|
+
name: 'OpenStreetMap',
|
|
15915
|
+
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
|
15916
|
+
...options,
|
|
15917
|
+
url,
|
|
15918
|
+
});
|
|
15919
|
+
}
|
|
15920
|
+
}
|
|
15921
|
+
|
|
15910
15922
|
class WmsLayerBase extends leafletSrc.exports.TileLayer.WMS {
|
|
15911
15923
|
constructor(urlTemplate, options) {
|
|
15912
15924
|
super(urlTemplate, options);
|
|
@@ -15940,18 +15952,6 @@ class WmsAdapter extends BaseAdapter {
|
|
|
15940
15952
|
}
|
|
15941
15953
|
}
|
|
15942
15954
|
|
|
15943
|
-
class OsmAdapter extends TileAdapter {
|
|
15944
|
-
addLayer(options) {
|
|
15945
|
-
const url = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
|
15946
|
-
return super.addLayer({
|
|
15947
|
-
name: 'OpenStreetMap',
|
|
15948
|
-
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
|
15949
|
-
...options,
|
|
15950
|
-
url,
|
|
15951
|
-
});
|
|
15952
|
-
}
|
|
15953
|
-
}
|
|
15954
|
-
|
|
15955
15955
|
function arrayToBoundsExpression(bounds) {
|
|
15956
15956
|
const e = bounds;
|
|
15957
15957
|
// top, left, bottom, right
|