@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.
@@ -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
  var LeafletMapAdapter = (function () {
3
3
  'use strict';
4
4
 
@@ -14976,12 +14976,13 @@ var LeafletMapAdapter = (function () {
14976
14976
  this._removeMapListener();
14977
14977
  };
14978
14978
  GeoJsonAdapter.prototype.select = function (findFeatureFun) {
14979
- var _this = this;
14979
+ this.unselect();
14980
14980
  if (findFeatureFun) {
14981
14981
  var def = this._layers.filter(findFeatureFun);
14982
- def.forEach(function (x) {
14983
- _this._selectLayer(x, 'api');
14984
- });
14982
+ for (var _i = 0, def_1 = def; _i < def_1.length; _i++) {
14983
+ var x = def_1[_i];
14984
+ this._selectLayer(x, 'api');
14985
+ }
14985
14986
  }
14986
14987
  else if (!this.selected) {
14987
14988
  this.selected = true;
@@ -15394,13 +15395,13 @@ var LeafletMapAdapter = (function () {
15394
15395
  var _this = this;
15395
15396
  var layer_ = this.layer;
15396
15397
  if (layer_) {
15397
- var def_1 = __assign({ target: this, feature: feature, layer: layer }, createFeaturePositionOptions(feature));
15398
+ var def_2 = __assign({ target: this, feature: feature, layer: layer }, createFeaturePositionOptions(feature));
15398
15399
  // @ts-ignore
15399
15400
  layer.options.pane = this.pane;
15400
- this._layers.push(def_1);
15401
+ this._layers.push(def_2);
15401
15402
  var ok = true;
15402
15403
  if (this._filterFun) {
15403
- ok = this._filterFun(def_1);
15404
+ ok = this._filterFun(def_2);
15404
15405
  }
15405
15406
  if (ok) {
15406
15407
  var _a = this.options, popup_1 = _a.popup, popupOptions_1 = _a.popupOptions, selectable = _a.selectable, interactive = _a.interactive, selectOnHover = _a.selectOnHover;
@@ -15410,10 +15411,10 @@ var LeafletMapAdapter = (function () {
15410
15411
  if (selectable) {
15411
15412
  if (selectOnHover) {
15412
15413
  layer.on('mouseover', function () {
15413
- _this._selectLayer(def_1, 'hover');
15414
+ _this._selectLayer(def_2, 'hover');
15414
15415
  });
15415
15416
  layer.on('mouseout', function () {
15416
- _this._unSelectLayer(def_1);
15417
+ _this._unSelectLayer(def_2);
15417
15418
  });
15418
15419
  }
15419
15420
  else {
@@ -15480,10 +15481,12 @@ var LeafletMapAdapter = (function () {
15480
15481
  };
15481
15482
  GeoJsonAdapter.prototype._selectLayer = function (def, type, latlng) {
15482
15483
  var _this = this;
15483
- this.map._addUnselectCb(function () {
15484
- _this._unSelectLayer(def);
15485
- });
15486
- if (this.options && !this.options.multiselect) {
15484
+ var multiselect = this.options.multiselect;
15485
+ if (!multiselect) {
15486
+ // To unselect layer on another layer click
15487
+ this.map._addUnselectCb(function () {
15488
+ _this._unSelectLayer(def);
15489
+ });
15487
15490
  this._selectedLayers.forEach(function (x) { return _this._unSelectLayer(x); });
15488
15491
  }
15489
15492
  this._selectedLayers.push(def);
@@ -15560,14 +15563,26 @@ var LeafletMapAdapter = (function () {
15560
15563
  }
15561
15564
  return geoJsonOptions;
15562
15565
  };
15563
- GeoJsonAdapter.prototype._addMapListener = function () {
15566
+ GeoJsonAdapter.prototype._addMapClickListener = function () {
15564
15567
  var map = this.map;
15565
15568
  if (map) {
15566
- var _a = this.options, labelField = _a.labelField, labelOnHover = _a.labelOnHover, unselectOnClick = _a.unselectOnClick;
15569
+ var unselectOnClick = this.options.unselectOnClick;
15567
15570
  var uoc = unselectOnClick !== null && unselectOnClick !== void 0 ? unselectOnClick : true;
15568
15571
  if (uoc) {
15569
15572
  map.on('click', this.$unselect);
15570
15573
  }
15574
+ }
15575
+ };
15576
+ GeoJsonAdapter.prototype._removeMapClickListener = function () {
15577
+ this.map.off('zoomend', this.$updateTooltip);
15578
+ this.map.off('moveend', this.$updateTooltip);
15579
+ this.map.off('click', this.$unselect);
15580
+ };
15581
+ GeoJsonAdapter.prototype._addMapListener = function () {
15582
+ var map = this.map;
15583
+ if (map) {
15584
+ var _a = this.options, labelField = _a.labelField, labelOnHover = _a.labelOnHover;
15585
+ this._addMapClickListener();
15571
15586
  if (labelField && !labelOnHover) {
15572
15587
  map.on('zoomend', this.$updateTooltip);
15573
15588
  map.on('moveend', this.$updateTooltip);
@@ -15575,9 +15590,9 @@ var LeafletMapAdapter = (function () {
15575
15590
  }
15576
15591
  };
15577
15592
  GeoJsonAdapter.prototype._removeMapListener = function () {
15593
+ this._removeMapClickListener();
15578
15594
  this.map.off('zoomend', this.$updateTooltip);
15579
15595
  this.map.off('moveend', this.$updateTooltip);
15580
- this.map.off('click', this.$unselect);
15581
15596
  };
15582
15597
  return GeoJsonAdapter;
15583
15598
  }(BaseAdapter));