@nextgis/leaflet-map-adapter 4.1.0 → 4.1.3

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.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/leaflet-map-adapter; version: 4.1.0; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 4.1.3; author: NextGIS */
2
2
  import { LeafletControlContainer, createControl, createButtonControl, createToggleControl } from '@nextgis/leaflet-control-container';
3
3
  import { EventEmitter } from 'events';
4
4
  import { Control, GeoJSON, DomEvent, DivIcon, Marker, CircleMarker, FeatureGroup, ImageOverlay as ImageOverlay$1, Util, Layer, GridLayer, DomUtil, TileLayer as TileLayer$1, Map, latLngBounds, latLng } from 'leaflet';
@@ -104,6 +104,8 @@ function filterGeometries(data, type) {
104
104
  _data.geometries = _data.geometries.filter(
105
105
  (g) => geometryFilter(g.type, type)
106
106
  );
107
+ } else if (!geometryFilter(data.type, type)) {
108
+ return false;
107
109
  }
108
110
  return data;
109
111
  }
@@ -642,6 +644,9 @@ class GeoJsonAdapter extends BaseAdapter {
642
644
  }
643
645
  setData(data) {
644
646
  this.clearLayer();
647
+ if (!this.options.type) {
648
+ this.type = void 0;
649
+ }
645
650
  this.addData(data);
646
651
  }
647
652
  addData(data) {
@@ -656,15 +661,20 @@ class GeoJsonAdapter extends BaseAdapter {
656
661
  } else {
657
662
  type = options.type;
658
663
  }
664
+ if (!type) {
665
+ return;
666
+ }
659
667
  if (this.type && this.type !== type) {
660
668
  console.warn("no other data type than layer can be added");
661
669
  return;
662
670
  }
663
671
  this.type = type;
664
672
  data = filterGeometries(data, type);
665
- if (data) {
666
- geoJsonOptions = this._getGeoJsonOptions(options, type);
673
+ if (!data) {
674
+ console.warn("no other data type than layer can be added");
675
+ return;
667
676
  }
677
+ geoJsonOptions = this._getGeoJsonOptions(options, type);
668
678
  }
669
679
  new GeoJSON(data || void 0, geoJsonOptions);
670
680
  }
@@ -1887,10 +1897,10 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
1887
1897
  }
1888
1898
  const stop2 = () => {
1889
1899
  if (locationfound !== void 0) {
1890
- map.off("locationfound", locationFound);
1900
+ map.off("locationfound", locationFound, this);
1891
1901
  }
1892
1902
  if (locationerror) {
1893
- map.off("locationerror", locationerror);
1903
+ map.off("locationerror", locationerror, this);
1894
1904
  }
1895
1905
  };
1896
1906
  return { stop: stop2 };
@@ -1912,6 +1922,10 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
1912
1922
  const map = this.map;
1913
1923
  if (container && map && window.ResizeObserver) {
1914
1924
  this._resizeObserver = new ResizeObserver(() => {
1925
+ map.invalidateSize({
1926
+ pan: false,
1927
+ debounceMoveend: true
1928
+ });
1915
1929
  this._updateMinZoomForBounds();
1916
1930
  });
1917
1931
  this._resizeObserver.observe(container);