@nextgis/leaflet-map-adapter 1.15.0 → 1.16.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/README.md CHANGED
@@ -7,9 +7,9 @@ WebMap adapter to use [Leaflet](https://leafletjs.com/) GIS framework.
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- $ npm install --save-dev @nextgis/leaflet-map-adapter
10
+ $ npm install --save-dev leaflet @nextgis/leaflet-map-adapter
11
11
  # or
12
- $ yarn add @nextgis/leaflet-map-adapter
12
+ $ yarn add leaflet @nextgis/leaflet-map-adapter
13
13
  ```
14
14
 
15
15
  ## Usage
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/leaflet-map-adapter; version: 1.15.0; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 1.16.1; author: NextGIS */
2
2
  /******************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -14973,12 +14973,13 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
14973
14973
  this._removeMapListener();
14974
14974
  };
14975
14975
  GeoJsonAdapter.prototype.select = function (findFeatureFun) {
14976
- var _this = this;
14976
+ this.unselect();
14977
14977
  if (findFeatureFun) {
14978
14978
  var def = this._layers.filter(findFeatureFun);
14979
- def.forEach(function (x) {
14980
- _this._selectLayer(x, 'api');
14981
- });
14979
+ for (var _i = 0, def_1 = def; _i < def_1.length; _i++) {
14980
+ var x = def_1[_i];
14981
+ this._selectLayer(x, 'api');
14982
+ }
14982
14983
  }
14983
14984
  else if (!this.selected) {
14984
14985
  this.selected = true;
@@ -15391,13 +15392,13 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
15391
15392
  var _this = this;
15392
15393
  var layer_ = this.layer;
15393
15394
  if (layer_) {
15394
- var def_1 = __assign({ target: this, feature: feature, layer: layer }, createFeaturePositionOptions(feature));
15395
+ var def_2 = __assign({ target: this, feature: feature, layer: layer }, createFeaturePositionOptions(feature));
15395
15396
  // @ts-ignore
15396
15397
  layer.options.pane = this.pane;
15397
- this._layers.push(def_1);
15398
+ this._layers.push(def_2);
15398
15399
  var ok = true;
15399
15400
  if (this._filterFun) {
15400
- ok = this._filterFun(def_1);
15401
+ ok = this._filterFun(def_2);
15401
15402
  }
15402
15403
  if (ok) {
15403
15404
  var _a = this.options, popup_1 = _a.popup, popupOptions_1 = _a.popupOptions, selectable = _a.selectable, interactive = _a.interactive, selectOnHover = _a.selectOnHover;
@@ -15407,10 +15408,10 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
15407
15408
  if (selectable) {
15408
15409
  if (selectOnHover) {
15409
15410
  layer.on('mouseover', function () {
15410
- _this._selectLayer(def_1, 'hover');
15411
+ _this._selectLayer(def_2, 'hover');
15411
15412
  });
15412
15413
  layer.on('mouseout', function () {
15413
- _this._unSelectLayer(def_1);
15414
+ _this._unSelectLayer(def_2);
15414
15415
  });
15415
15416
  }
15416
15417
  else {
@@ -15477,10 +15478,12 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
15477
15478
  };
15478
15479
  GeoJsonAdapter.prototype._selectLayer = function (def, type, latlng) {
15479
15480
  var _this = this;
15480
- this.map._addUnselectCb(function () {
15481
- _this._unSelectLayer(def);
15482
- });
15483
- if (this.options && !this.options.multiselect) {
15481
+ var multiselect = this.options.multiselect;
15482
+ if (!multiselect) {
15483
+ // To unselect layer on another layer click
15484
+ this.map._addUnselectCb(function () {
15485
+ _this._unSelectLayer(def);
15486
+ });
15484
15487
  this._selectedLayers.forEach(function (x) { return _this._unSelectLayer(x); });
15485
15488
  }
15486
15489
  this._selectedLayers.push(def);
@@ -15557,14 +15560,26 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
15557
15560
  }
15558
15561
  return geoJsonOptions;
15559
15562
  };
15560
- GeoJsonAdapter.prototype._addMapListener = function () {
15563
+ GeoJsonAdapter.prototype._addMapClickListener = function () {
15561
15564
  var map = this.map;
15562
15565
  if (map) {
15563
- var _a = this.options, labelField = _a.labelField, labelOnHover = _a.labelOnHover, unselectOnClick = _a.unselectOnClick;
15566
+ var unselectOnClick = this.options.unselectOnClick;
15564
15567
  var uoc = unselectOnClick !== null && unselectOnClick !== void 0 ? unselectOnClick : true;
15565
15568
  if (uoc) {
15566
15569
  map.on('click', this.$unselect);
15567
15570
  }
15571
+ }
15572
+ };
15573
+ GeoJsonAdapter.prototype._removeMapClickListener = function () {
15574
+ this.map.off('zoomend', this.$updateTooltip);
15575
+ this.map.off('moveend', this.$updateTooltip);
15576
+ this.map.off('click', this.$unselect);
15577
+ };
15578
+ GeoJsonAdapter.prototype._addMapListener = function () {
15579
+ var map = this.map;
15580
+ if (map) {
15581
+ var _a = this.options, labelField = _a.labelField, labelOnHover = _a.labelOnHover;
15582
+ this._addMapClickListener();
15568
15583
  if (labelField && !labelOnHover) {
15569
15584
  map.on('zoomend', this.$updateTooltip);
15570
15585
  map.on('moveend', this.$updateTooltip);
@@ -15572,9 +15587,9 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
15572
15587
  }
15573
15588
  };
15574
15589
  GeoJsonAdapter.prototype._removeMapListener = function () {
15590
+ this._removeMapClickListener();
15575
15591
  this.map.off('zoomend', this.$updateTooltip);
15576
15592
  this.map.off('moveend', this.$updateTooltip);
15577
- this.map.off('click', this.$unselect);
15578
15593
  };
15579
15594
  return GeoJsonAdapter;
15580
15595
  }(BaseAdapter));