@nextgis/ngw-leaflet 1.18.3 → 1.18.9

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/ngw-leaflet; version: 1.18.3; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.18.9; author: NextGIS */
2
2
  import 'leaflet/dist/leaflet.css';
3
3
  import { Icon } from 'leaflet';
4
4
  import { NgwMap } from '@nextgis/ngw-map';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-leaflet; version: 1.18.3; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.18.9; author: NextGIS */
2
2
  var NgwLeaflet = (function () {
3
3
  'use strict';
4
4
 
@@ -19584,10 +19584,11 @@ var NgwLeaflet = (function () {
19584
19584
  */
19585
19585
  NgwConnector.prototype.apiRequest = function (name, params_, requestOptions) {
19586
19586
  var _this = this;
19587
- var _a;
19587
+ var _a, _b;
19588
19588
  if (params_ === void 0) { params_ = {}; }
19589
19589
  if (requestOptions === void 0) { requestOptions = {}; }
19590
19590
  var method = requestOptions.method, headers = requestOptions.headers, withCredentials = requestOptions.withCredentials, responseType = requestOptions.responseType;
19591
+ params_ = (_a = requestOptions.params) !== null && _a !== void 0 ? _a : params_;
19591
19592
  var params = objectRemoveEmpty(params_);
19592
19593
  var makeApiRequest = function () {
19593
19594
  return apiRequest({ name: name, params: params, requestOptions: requestOptions, connector: _this });
@@ -19599,7 +19600,7 @@ var NgwLeaflet = (function () {
19599
19600
  withCredentials: withCredentials,
19600
19601
  responseType: responseType,
19601
19602
  baseUrl: this.options.baseUrl,
19602
- userId: (_a = this.user) === null || _a === void 0 ? void 0 : _a.id,
19603
+ userId: (_b = this.user) === null || _b === void 0 ? void 0 : _b.id,
19603
19604
  })));
19604
19605
  }
19605
19606
  return makeApiRequest();
@@ -20052,8 +20053,11 @@ var NgwLeaflet = (function () {
20052
20053
  }
20053
20054
  function updateItemRequestParam(params, options) {
20054
20055
  var extensions = options.extensions, geom = options.geom, fields = options.fields, srs = options.srs, ilike = options.ilike, like = options.like;
20055
- if (extensions) {
20056
- params.extensions = extensions.join(',');
20056
+ // Empty extesions by default
20057
+ var extensionsStr = extensions ? extensions.join(',') : '';
20058
+ // Use character * to set all extensions
20059
+ if (extensionsStr !== '*') {
20060
+ params.extensions = extensionsStr;
20057
20061
  }
20058
20062
  if (fields !== undefined) {
20059
20063
  params.fields = Array.isArray(fields) ? fields.join(',') : '';
@@ -22992,11 +22996,12 @@ var NgwLeaflet = (function () {
22992
22996
  minus: '<path d="m12 7.5v-3h-12v3z"/>',
22993
22997
  asterisk: '<path d="m7.59 12v-3.27l2.83 1.64 1.58-2.74-2.85-1.64 2.83-1.64-1.56-2.74-2.83 1.64v-3.24h-3.17v3.24l-2.85-1.64-1.57 2.74 2.84 1.64-2.84 1.64 1.57 2.74 2.85-1.64v3.27z"/>',
22994
22998
  };
22999
+ var VIEW_BOX = 12;
22995
23000
  var STROKE = 0.8;
22996
- function generateSvg(width, height, stroke, content) {
22997
- if (stroke === void 0) { stroke = 0; }
23001
+ function generateSvg(_a) {
23002
+ var width = _a.width, height = _a.height, _b = _a.stroke, stroke = _b === void 0 ? 0 : _b, content = _a.content;
22998
23003
  var s = stroke / 2;
22999
- var svg = "<svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"".concat(width, "\"\n height=\"").concat(height, "\"\n viewBox=\"-").concat(s, " -").concat(s, " ").concat(width + stroke, " ").concat(height + stroke, "\"\n >").concat(content, "</svg>");
23004
+ var svg = "<svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"".concat(width, "\"\n height=\"").concat(height, "\"\n viewBox=\"-").concat(s, " -").concat(s, " ").concat(VIEW_BOX + stroke, " ").concat(VIEW_BOX + stroke, "\"\n >").concat(content, "</svg>");
23000
23005
  return svg;
23001
23006
  }
23002
23007
  function insertSvg(svg) {
@@ -23004,37 +23009,46 @@ var NgwLeaflet = (function () {
23004
23009
  var oDOM = oParser.parseFromString(svg, 'image/svg+xml');
23005
23010
  return oDOM.documentElement;
23006
23011
  }
23012
+ /**
23013
+ * Retrieves an icon with the provided options.
23014
+ * @function
23015
+ * @param {IconOptions} [opt={}] - Options for the icon.
23016
+ * @returns {IconPaint} Icon paint object.
23017
+ */
23007
23018
  function getIcon(opt) {
23008
- var _a, _b, _c, _d, _e;
23019
+ var _a, _b, _c, _d, _e, _f;
23009
23020
  if (opt === void 0) { opt = {}; }
23010
- // default values
23021
+ // Default values
23011
23022
  var shape = (_a = opt.shape) !== null && _a !== void 0 ? _a : 'circle';
23012
23023
  var color = (_b = opt.color) !== null && _b !== void 0 ? _b : 'blue';
23013
23024
  var strokeColor = (_c = opt.strokeColor) !== null && _c !== void 0 ? _c : 'white';
23014
- var size = (_d = opt.size) !== null && _d !== void 0 ? _d : 12;
23025
+ var size = (_d = opt.size) !== null && _d !== void 0 ? _d : VIEW_BOX;
23015
23026
  var rotate = (_e = opt.rotate) !== null && _e !== void 0 ? _e : 0;
23016
- var anchor = size / 2;
23017
- var defSize = 12;
23027
+ var anchor = (_f = opt.anchor) !== null && _f !== void 0 ? _f : [size / 2, size / 2];
23018
23028
  var stroke = opt.stroke !== undefined ? Number(opt.stroke) : STROKE;
23019
- var scale = size / defSize;
23020
23029
  var pathAlias = opt.p || svgPath[shape] || 'circle';
23021
23030
  var path = typeof pathAlias === 'string' ? pathAlias : pathAlias(opt);
23022
- var svg = insertSvg(opt.svg || generateSvg(size, size, stroke * scale, path));
23023
- var fistChild = svg.firstChild;
23024
- var scaledAnchor = defSize / 2;
23025
- var transform = "scale(".concat(scale, ") rotate(").concat(rotate, ", ").concat(scaledAnchor, ", ").concat(scaledAnchor, ")");
23026
- fistChild.setAttribute('fill', color);
23031
+ var svg = insertSvg(opt.svg ||
23032
+ generateSvg({
23033
+ width: size,
23034
+ height: size,
23035
+ stroke: stroke,
23036
+ content: path,
23037
+ }));
23038
+ svg.setAttribute('width', String(size));
23039
+ svg.setAttribute('height', String(size));
23040
+ svg.setAttribute('fill', color);
23027
23041
  if (stroke) {
23028
- fistChild.setAttribute('stroke', strokeColor);
23029
- fistChild.setAttribute('stroke-width', String(stroke));
23042
+ svg.setAttribute('stroke', strokeColor);
23043
+ svg.setAttribute('stroke-width', String(stroke));
23030
23044
  }
23031
- fistChild.setAttribute('transform', transform);
23032
23045
  var s = new XMLSerializer();
23033
23046
  return {
23034
23047
  type: 'icon',
23035
23048
  iconSize: [size, size],
23036
- iconAnchor: [anchor, anchor],
23049
+ iconAnchor: anchor,
23037
23050
  html: s.serializeToString(svg),
23051
+ rotate: rotate,
23038
23052
  svg: svg,
23039
23053
  };
23040
23054
  }
@@ -23944,14 +23958,6 @@ var NgwLeaflet = (function () {
23944
23958
  };
23945
23959
  }
23946
23960
 
23947
- function createMouseEvent(_a) {
23948
- var layer = _a.layer, source = _a.source;
23949
- var layer_ = source.target;
23950
- var feature = layer_.feature;
23951
- var opt = __assign({ layer: layer, feature: feature, event: convertMapClickEvent(source), source: source }, createFeaturePositionOptions(feature));
23952
- return opt;
23953
- }
23954
-
23955
23961
  function findMostFrequentGeomType(arr) {
23956
23962
  var counts = {};
23957
23963
  for (var fry = 0; fry < arr.length; fry++) {
@@ -24007,6 +24013,195 @@ var NgwLeaflet = (function () {
24007
24013
  return BaseAdapter;
24008
24014
  }());
24009
24015
 
24016
+ function createMouseEvent(_a) {
24017
+ var layer = _a.layer, source = _a.source;
24018
+ var layer_ = source.target;
24019
+ var feature = layer_.feature;
24020
+ var opt = __assign({ layer: layer, feature: feature, event: convertMapClickEvent(source), source: source }, createFeaturePositionOptions(feature));
24021
+ return opt;
24022
+ }
24023
+
24024
+ var GeoJsonEvents = /** @class */ (function () {
24025
+ function GeoJsonEvents(layer) {
24026
+ this.layer = layer;
24027
+ }
24028
+ GeoJsonEvents.prototype.handleMouseEvents = function (layer) {
24029
+ var _this = this;
24030
+ var _a = this.layer.options, onClick = _a.onClick, onLayerClick = _a.onLayerClick, onMouseOut = _a.onMouseOut, onMouseOver = _a.onMouseOver;
24031
+ // TODO: remove backward compatibility for onLayerClick
24032
+ var onClick_ = onClick || onLayerClick;
24033
+ if (onClick_) {
24034
+ this._onclick = function (e) {
24035
+ var selected = !!_this.layer._getSelected(layer);
24036
+ onClick_(__assign({ selected: selected }, _this._createMouseEvent(e)));
24037
+ };
24038
+ layer.on('click', this._onclick, this);
24039
+ }
24040
+ if (onMouseOut) {
24041
+ this._mouseout = function (e) {
24042
+ onMouseOut(_this._createMouseEvent(e));
24043
+ };
24044
+ layer.on('mouseout', this._mouseout, this);
24045
+ }
24046
+ if (onMouseOver) {
24047
+ this._mouseover = function (e) {
24048
+ onMouseOver(_this._createMouseEvent(e));
24049
+ };
24050
+ layer.on('mouseover', this._mouseover, this);
24051
+ }
24052
+ };
24053
+ GeoJsonEvents.prototype.stopMouseEvents = function (layer) {
24054
+ if (this._mouseover) {
24055
+ layer.off('mouseover', this._mouseover, this);
24056
+ }
24057
+ if (this._mouseout) {
24058
+ layer.off('mouseout', this._mouseout, this);
24059
+ }
24060
+ if (this._onclick) {
24061
+ layer.off('click', this._onclick, this);
24062
+ }
24063
+ };
24064
+ GeoJsonEvents.prototype._createMouseEvent = function (source) {
24065
+ return createMouseEvent({
24066
+ layer: this.layer,
24067
+ source: source,
24068
+ });
24069
+ };
24070
+ return GeoJsonEvents;
24071
+ }());
24072
+
24073
+ var GeoJsonPaint = /** @class */ (function () {
24074
+ function GeoJsonPaint(layer) {
24075
+ this.layer = layer;
24076
+ }
24077
+ GeoJsonPaint.prototype.setPaintEachLayer = function (paint) {
24078
+ var _this = this;
24079
+ this.layer._layers.forEach(function (layerDef) {
24080
+ _this.setPaint(layerDef, paint);
24081
+ });
24082
+ };
24083
+ GeoJsonPaint.prototype.setPaint = function (layerDef, paint) {
24084
+ var style = undefined;
24085
+ var layer = layerDef.layer, feature = layerDef.feature;
24086
+ if (layer && feature) {
24087
+ if (isPaintCallback(paint)) {
24088
+ style = paint(feature);
24089
+ }
24090
+ else if (isPaint(paint)) {
24091
+ style = paint;
24092
+ }
24093
+ if (style) {
24094
+ if (this.layer.type === 'point' && style.type === 'icon') {
24095
+ var marker_1 = layer;
24096
+ var divIcon_1 = this._createDivIcon(style);
24097
+ setTimeout(function () {
24098
+ marker_1.setIcon(divIcon_1);
24099
+ }, 10);
24100
+ }
24101
+ else if ('setStyle' in layer) {
24102
+ layer.setStyle(this.preparePaint(style));
24103
+ }
24104
+ }
24105
+ }
24106
+ };
24107
+ GeoJsonPaint.prototype.preparePaint = function (paint) {
24108
+ if (paint.type !== 'get-paint') {
24109
+ var paintAliases = [
24110
+ ['color', 'strokeColor'],
24111
+ ['opacity', 'strokeOpacity'],
24112
+ ['stroke', 'stroke'],
24113
+ ['fillColor', 'fillColor'],
24114
+ ['fillOpacity', 'fillOpacity'],
24115
+ ['fill', 'fill'],
24116
+ ['weight', 'weight'],
24117
+ ];
24118
+ var aliases = this.layer.type === 'line'
24119
+ ? [
24120
+ ['color', 'strokeColor'],
24121
+ ['opacity', 'strokeOpacity'],
24122
+ ['weight', 'weight'],
24123
+ ]
24124
+ : paintAliases;
24125
+ var readyPaint = {};
24126
+ if ('radius' in paint && typeof paint.radius === 'number') {
24127
+ readyPaint.radius = paint.radius;
24128
+ }
24129
+ for (var _i = 0, aliases_1 = aliases; _i < aliases_1.length; _i++) {
24130
+ var _a = aliases_1[_i], to = _a[0], from = _a[1];
24131
+ var opacity = this.layer.options.opacity;
24132
+ var paintProp = paint[from];
24133
+ if (defined(opacity) && from.toLowerCase().indexOf('opacity') !== -1) {
24134
+ paintProp = Number(paintProp) * opacity;
24135
+ }
24136
+ if (paintProp !== undefined) {
24137
+ Object.defineProperty(readyPaint, to, {
24138
+ enumerable: true,
24139
+ value: paintProp,
24140
+ });
24141
+ }
24142
+ }
24143
+ return readyPaint;
24144
+ }
24145
+ return PAINT;
24146
+ };
24147
+ GeoJsonPaint.prototype._createDivIcon = function (icon) {
24148
+ var html = icon.html, rotate = icon.rotate, className = icon.className, toLIconOpt = __rest(icon, ["html", "rotate", "className"]);
24149
+ var element = document.createElement('div');
24150
+ if (className) {
24151
+ element.className = className;
24152
+ }
24153
+ if (rotate) {
24154
+ element.style.transform = "rotateZ(".concat(rotate, "deg)");
24155
+ }
24156
+ if (html) {
24157
+ element.innerHTML = html;
24158
+ }
24159
+ var divIcon = new leafletSrc.exports.DivIcon(__assign(__assign({ className: '' }, toLIconOpt), { html: element }));
24160
+ return divIcon;
24161
+ };
24162
+ GeoJsonPaint.prototype.createPaintToLayer = function (icon) {
24163
+ var _this = this;
24164
+ if (icon && icon.type) {
24165
+ if (icon.type === 'icon') {
24166
+ var iconClassName = icon.className;
24167
+ var html = icon.html;
24168
+ if (iconClassName || html) {
24169
+ return function (_, latlng) {
24170
+ var divIcon = _this._createDivIcon(icon);
24171
+ return new leafletSrc.exports.Marker(latlng, { icon: divIcon });
24172
+ };
24173
+ }
24174
+ }
24175
+ else if (icon.type === 'pin') {
24176
+ return function (_, latlng) {
24177
+ return new leafletSrc.exports.Marker(latlng);
24178
+ };
24179
+ }
24180
+ }
24181
+ return function (_, latlng) {
24182
+ var p = PAINT;
24183
+ return new leafletSrc.exports.CircleMarker(latlng, _this.preparePaint(__assign(__assign({}, p), icon)));
24184
+ };
24185
+ };
24186
+ GeoJsonPaint.prototype.createPaintOptions = function (paint) {
24187
+ var geoJsonOptions = {};
24188
+ var newPaint = this.preparePaint(paint);
24189
+ if (paint) {
24190
+ geoJsonOptions.style = function () {
24191
+ return newPaint;
24192
+ };
24193
+ }
24194
+ if (this.layer.type === 'point') {
24195
+ geoJsonOptions.pointToLayer = this.createPaintToLayer(paint);
24196
+ }
24197
+ else if (this.layer.type === 'line') {
24198
+ newPaint.stroke = true;
24199
+ }
24200
+ return geoJsonOptions;
24201
+ };
24202
+ return GeoJsonPaint;
24203
+ }());
24204
+
24010
24205
  var GeoJsonAdapter = /** @class */ (function (_super) {
24011
24206
  __extends(GeoJsonAdapter, _super);
24012
24207
  function GeoJsonAdapter(map, options) {
@@ -24022,6 +24217,8 @@ var NgwLeaflet = (function () {
24022
24217
  _this.$unselect = function () {
24023
24218
  _this.unselect();
24024
24219
  };
24220
+ _this._events = new GeoJsonEvents(_this);
24221
+ _this._paint = new GeoJsonPaint(_this);
24025
24222
  return _this;
24026
24223
  }
24027
24224
  GeoJsonAdapter.prototype.addLayer = function (options) {
@@ -24051,7 +24248,7 @@ var NgwLeaflet = (function () {
24051
24248
  else if (!this.selected) {
24052
24249
  this.selected = true;
24053
24250
  if (this.selectedPaint) {
24054
- this._setPaintEachLayer(this.selectedPaint);
24251
+ this._paint.setPaintEachLayer(this.selectedPaint);
24055
24252
  }
24056
24253
  }
24057
24254
  };
@@ -24069,7 +24266,7 @@ var NgwLeaflet = (function () {
24069
24266
  this._removePopup(p[0]);
24070
24267
  }
24071
24268
  if (this.paint) {
24072
- this._setPaintEachLayer(this.paint);
24269
+ this._paint.setPaintEachLayer(this.paint);
24073
24270
  }
24074
24271
  this._selectedLayers.length = 0;
24075
24272
  this.selected = false;
@@ -24230,7 +24427,7 @@ var NgwLeaflet = (function () {
24230
24427
  this.paint = paint;
24231
24428
  for (var _i = 0, _a = this._layers; _i < _a.length; _i++) {
24232
24429
  var l = _a[_i];
24233
- this._setPaint(l, paint);
24430
+ this._paint.setPaint(l, paint);
24234
24431
  }
24235
24432
  }
24236
24433
  };
@@ -24239,7 +24436,7 @@ var NgwLeaflet = (function () {
24239
24436
  this.selectedPaint = paint;
24240
24437
  for (var _i = 0, _a = this._selectedLayers; _i < _a.length; _i++) {
24241
24438
  var l = _a[_i];
24242
- this._setPaint(l, paint);
24439
+ this._paint.setPaint(l, paint);
24243
24440
  }
24244
24441
  }
24245
24442
  };
@@ -24247,16 +24444,19 @@ var NgwLeaflet = (function () {
24247
24444
  this.paint = __assign(__assign({}, this.paint), paint);
24248
24445
  for (var _i = 0, _a = this._layers; _i < _a.length; _i++) {
24249
24446
  var l = _a[_i];
24250
- this._setPaint(l, this.paint);
24447
+ this._paint.setPaint(l, this.paint);
24251
24448
  }
24252
24449
  };
24253
24450
  GeoJsonAdapter.prototype.updateSelectedPaint = function (paint) {
24254
24451
  this.selectedPaint = __assign(__assign({}, this.selectedPaint), paint);
24255
24452
  for (var _i = 0, _a = this._selectedLayers; _i < _a.length; _i++) {
24256
24453
  var l = _a[_i];
24257
- this._setPaint(l, this.selectedPaint);
24454
+ this._paint.setPaint(l, this.selectedPaint);
24258
24455
  }
24259
24456
  };
24457
+ GeoJsonAdapter.prototype._getSelected = function (layer) {
24458
+ return this._selectedLayers.find(function (x) { return x.layer === layer; });
24459
+ };
24260
24460
  GeoJsonAdapter.prototype._updateTooltip = function (layerDef) {
24261
24461
  var feature = layerDef.feature, layer = layerDef.layer;
24262
24462
  if (feature && layer && feature.properties && this.options.labelField) {
@@ -24348,79 +24548,6 @@ var NgwLeaflet = (function () {
24348
24548
  }
24349
24549
  }
24350
24550
  };
24351
- GeoJsonAdapter.prototype._setPaintEachLayer = function (paint) {
24352
- var _this = this;
24353
- this._layers.forEach(function (l) {
24354
- _this._setPaint(l, paint);
24355
- });
24356
- };
24357
- GeoJsonAdapter.prototype._setPaint = function (def, paint) {
24358
- var style = undefined;
24359
- var layer = def.layer, feature = def.feature;
24360
- if (layer && feature) {
24361
- if (isPaintCallback(paint)) {
24362
- style = paint(feature);
24363
- }
24364
- else if (isPaint(paint)) {
24365
- style = paint;
24366
- }
24367
- if (style) {
24368
- if (this.type === 'point' && style.type === 'icon') {
24369
- var marker = layer;
24370
- var divIcon = this._createDivIcon(style);
24371
- marker.setIcon(divIcon);
24372
- }
24373
- else if ('setStyle' in layer) {
24374
- layer.setStyle(this._preparePaint(style));
24375
- }
24376
- }
24377
- }
24378
- };
24379
- GeoJsonAdapter.prototype._preparePaint = function (paint) {
24380
- if (paint.type !== 'get-paint') {
24381
- // const path: CircleMarkerOptions | PathOptions = paint as CircleMarkerOptions | PathOptions;
24382
- // if (path.opacity) {
24383
- // path.fillOpacity = path.opacity;
24384
- // }
24385
- var paintAliases = [
24386
- // ['color', 'color'],
24387
- ['color', 'strokeColor'],
24388
- ['opacity', 'strokeOpacity'],
24389
- ['stroke', 'stroke'],
24390
- ['fillColor', 'fillColor'],
24391
- ['fillOpacity', 'fillOpacity'],
24392
- ['fill', 'fill'],
24393
- ['weight', 'weight'],
24394
- ];
24395
- var aliases = this.type === 'line'
24396
- ? [
24397
- ['color', 'strokeColor'],
24398
- ['opacity', 'strokeOpacity'],
24399
- ['weight', 'weight'],
24400
- ]
24401
- : paintAliases;
24402
- var readyPaint = {};
24403
- if ('radius' in paint && typeof paint.radius === 'number') {
24404
- readyPaint.radius = paint.radius;
24405
- }
24406
- for (var _i = 0, aliases_1 = aliases; _i < aliases_1.length; _i++) {
24407
- var _a = aliases_1[_i], to = _a[0], from = _a[1];
24408
- var paintProp = paint[from];
24409
- if (defined(this.options.opacity) &&
24410
- from.toLowerCase().indexOf('opacity') !== -1) {
24411
- paintProp = Number(paintProp) * this.options.opacity;
24412
- }
24413
- if (paintProp !== undefined) {
24414
- Object.defineProperty(readyPaint, to, {
24415
- enumerable: true,
24416
- value: paintProp,
24417
- });
24418
- }
24419
- }
24420
- return readyPaint;
24421
- }
24422
- return PAINT;
24423
- };
24424
24551
  GeoJsonAdapter.prototype._getGeoJsonOptions = function (options, type) {
24425
24552
  var _this = this;
24426
24553
  var paint = options.paint;
@@ -24430,7 +24557,7 @@ var NgwLeaflet = (function () {
24430
24557
  // TODO: fix types (@geoman-io/leaflet-geoman-free)
24431
24558
  lopt.pointToLayer = function (feature, latLng) {
24432
24559
  var iconOpt = paint(feature);
24433
- var pointToLayer = _this._createPaintToLayer(iconOpt);
24560
+ var pointToLayer = _this._paint.createPaintToLayer(iconOpt);
24434
24561
  return pointToLayer(feature, latLng);
24435
24562
  };
24436
24563
  }
@@ -24438,17 +24565,17 @@ var NgwLeaflet = (function () {
24438
24565
  lopt = {
24439
24566
  style: function (feature) {
24440
24567
  if (feature) {
24441
- return _this._preparePaint(__assign(__assign({}, PAINT), paint(feature)));
24568
+ return _this._paint.preparePaint(__assign(__assign({}, PAINT), paint(feature)));
24442
24569
  }
24443
24570
  else {
24444
- return _this._preparePaint(__assign(__assign({}, PAINT), { type: 'path' }));
24571
+ return _this._paint.preparePaint(__assign(__assign({}, PAINT), { type: 'path' }));
24445
24572
  }
24446
24573
  },
24447
24574
  };
24448
24575
  }
24449
24576
  }
24450
24577
  else {
24451
- lopt = this._createPaintOptions(paint, type);
24578
+ lopt = this._paint.createPaintOptions(paint);
24452
24579
  }
24453
24580
  lopt.onEachFeature = function (feature, layer) {
24454
24581
  _this._onEachFeature(feature, layer);
@@ -24460,7 +24587,6 @@ var NgwLeaflet = (function () {
24460
24587
  var layer_ = this.layer;
24461
24588
  if (layer_) {
24462
24589
  var def_2 = __assign({ target: this, feature: feature, layer: layer }, createFeaturePositionOptions(feature));
24463
- // @ts-ignore
24464
24590
  layer.options.pane = this.pane;
24465
24591
  this._layers.push(def_2);
24466
24592
  var ok = true;
@@ -24485,7 +24611,7 @@ var NgwLeaflet = (function () {
24485
24611
  layer.on('click', function (e) { return _this._selectOnLayerClick(e); }, this);
24486
24612
  }
24487
24613
  }
24488
- this._handleMouseEvents(layer);
24614
+ this._events.handleMouseEvents(layer);
24489
24615
  // The timeout is needed to display the popup immediately when adding a layer to the map.
24490
24616
  // Without a timeout, the layer may not yet have a _map object
24491
24617
  setTimeout(function () {
@@ -24497,37 +24623,6 @@ var NgwLeaflet = (function () {
24497
24623
  }
24498
24624
  }
24499
24625
  };
24500
- GeoJsonAdapter.prototype._handleMouseEvents = function (layer) {
24501
- var _this = this;
24502
- var _a = this.options, onClick = _a.onClick, onLayerClick = _a.onLayerClick, onMouseOut = _a.onMouseOut, onMouseOver = _a.onMouseOver;
24503
- // TODO: remove backward compatibility for onLayerClick
24504
- var onClick_ = onClick || onLayerClick;
24505
- if (onClick_) {
24506
- layer.on('click', function (e) {
24507
- var selected = !!_this._getSelected(layer);
24508
- onClick_(__assign({ selected: selected }, _this._createMouseEvent(e)));
24509
- }, this);
24510
- }
24511
- if (onMouseOut) {
24512
- layer.on('mouseout', function (e) {
24513
- onMouseOut(_this._createMouseEvent(e));
24514
- }, this);
24515
- }
24516
- if (onMouseOver) {
24517
- layer.on('mouseover', function (e) {
24518
- onMouseOver(_this._createMouseEvent(e));
24519
- }, this);
24520
- }
24521
- };
24522
- GeoJsonAdapter.prototype._createMouseEvent = function (source) {
24523
- return createMouseEvent({
24524
- layer: this,
24525
- source: source,
24526
- });
24527
- };
24528
- GeoJsonAdapter.prototype._getSelected = function (layer) {
24529
- return this._selectedLayers.find(function (x) { return x.layer === layer; });
24530
- };
24531
24626
  GeoJsonAdapter.prototype._selectOnLayerClick = function (e) {
24532
24627
  leafletSrc.exports.DomEvent.stopPropagation(e);
24533
24628
  var layer = e.target;
@@ -24557,7 +24652,7 @@ var NgwLeaflet = (function () {
24557
24652
  this.selected = true;
24558
24653
  var _a = this.options, selectedPaint = _a.selectedPaint, popupOnSelect = _a.popupOnSelect, popupOptions = _a.popupOptions;
24559
24654
  if (selectedPaint && def.layer) {
24560
- this._setPaint(def, selectedPaint);
24655
+ this._paint.setPaint(def, selectedPaint);
24561
24656
  }
24562
24657
  if (popupOnSelect) {
24563
24658
  this._openPopup(def, popupOptions, type, latlng);
@@ -24573,7 +24668,7 @@ var NgwLeaflet = (function () {
24573
24668
  this._selectedLayers.splice(index, 1);
24574
24669
  if (this.options) {
24575
24670
  if (this.options.paint) {
24576
- this._setPaint(def, this.options.paint);
24671
+ this._paint.setPaint(def, this.options.paint);
24577
24672
  }
24578
24673
  if (this.options.popupOnSelect && def.layer) {
24579
24674
  this._removePopup(def.layer);
@@ -24582,51 +24677,6 @@ var NgwLeaflet = (function () {
24582
24677
  }
24583
24678
  this.selected = this._selectedLayers.length > 0;
24584
24679
  };
24585
- GeoJsonAdapter.prototype._createDivIcon = function (icon) {
24586
- var toLIconOpt = __rest(icon, []);
24587
- return new leafletSrc.exports.DivIcon(__assign({ className: '' }, toLIconOpt));
24588
- };
24589
- GeoJsonAdapter.prototype._createPaintToLayer = function (icon) {
24590
- var _this = this;
24591
- if (icon && icon.type) {
24592
- if (icon.type === 'icon') {
24593
- var iconClassName = icon.className;
24594
- var html = icon.html;
24595
- if (iconClassName || html) {
24596
- return function (geoJsonPoint, latlng) {
24597
- var divIcon = _this._createDivIcon(icon);
24598
- return new leafletSrc.exports.Marker(latlng, { icon: divIcon });
24599
- };
24600
- }
24601
- }
24602
- else if (icon.type === 'pin') {
24603
- return function (geoJsonPoint, latlng) {
24604
- // const divIcon = this.createDivIcon(icon);
24605
- return new leafletSrc.exports.Marker(latlng);
24606
- };
24607
- }
24608
- }
24609
- return function (geoJsonPoint, latlng) {
24610
- var p = PAINT;
24611
- return new leafletSrc.exports.CircleMarker(latlng, _this._preparePaint(__assign(__assign({}, p), icon)));
24612
- };
24613
- };
24614
- GeoJsonAdapter.prototype._createPaintOptions = function (paintOptions, type) {
24615
- var geoJsonOptions = {};
24616
- var paint = (paintOptions && this._preparePaint(paintOptions)) || {};
24617
- if (paintOptions) {
24618
- geoJsonOptions.style = function () {
24619
- return paint;
24620
- };
24621
- }
24622
- if (type === 'point') {
24623
- geoJsonOptions.pointToLayer = this._createPaintToLayer(paintOptions);
24624
- }
24625
- else if (type === 'line') {
24626
- paint.stroke = true;
24627
- }
24628
- return geoJsonOptions;
24629
- };
24630
24680
  GeoJsonAdapter.prototype._addMapClickListener = function () {
24631
24681
  var map = this.map;
24632
24682
  if (map) {