@nextgis/ngw-leaflet 1.18.0 → 1.18.2

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.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.18.2; author: NextGIS */
2
2
  function styleInject(css, ref) {
3
3
  if ( ref === void 0 ) ref = {};
4
4
  var insertAt = ref.insertAt;
@@ -16038,32 +16038,43 @@ function createPropertiesPaint(propertiesPaint) {
16038
16038
  return mask;
16039
16039
  };
16040
16040
  }
16041
- function expressionCallback(paint, defaultPaint, getPaintFunctions) {
16041
+ function expressionCallback({ paint, defaultPaint, }) {
16042
16042
  const expressionCallback = createExpressionCallback(paint);
16043
16043
  if (expressionCallback) {
16044
16044
  const expressionPaintCb = (feature) => {
16045
- return preparePaint(expressionCallback(feature), defaultPaint, getPaintFunctions);
16045
+ return preparePaint({
16046
+ paint: expressionCallback(feature),
16047
+ defaultPaint,
16048
+ });
16046
16049
  };
16047
- expressionPaintCb.paint = paint;
16050
+ expressionPaintCb.paint = finalizePaint({ paint, defaultPaint });
16048
16051
  return expressionPaintCb;
16049
16052
  }
16053
+ return finalizePaint({ paint, defaultPaint });
16054
+ }
16055
+ function finalizePaint({ paint, defaultPaint }) {
16056
+ var _a;
16050
16057
  let newPaint = { ...defaultPaint };
16051
16058
  newPaint = { ...newPaint, ...paint };
16052
- newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
16059
+ newPaint.fill = (_a = newPaint.fill) !== null && _a !== void 0 ? _a : true;
16053
16060
  newPaint.stroke =
16054
16061
  newPaint.stroke !== undefined
16055
16062
  ? newPaint.stroke
16056
16063
  : !newPaint.fill || !!(newPaint.strokeColor || newPaint.strokeOpacity);
16057
16064
  return newPaint;
16058
16065
  }
16059
- function preparePaint(paint, defaultPaint, getPaintFunctions) {
16066
+ function preparePaint({ paint, defaultPaint, getPaintFunctions, }) {
16060
16067
  if (!paint) {
16061
16068
  throw new Error('paint is empty');
16062
16069
  }
16063
16070
  let newPaint = { ...defaultPaint };
16064
16071
  if (isPaintCallback(paint)) {
16065
16072
  const getPaintFunction = (feature) => {
16066
- const getPaint = preparePaint(paint(feature), defaultPaint, getPaintFunctions);
16073
+ const getPaint = preparePaint({
16074
+ paint: paint(feature),
16075
+ defaultPaint,
16076
+ getPaintFunctions,
16077
+ });
16067
16078
  getPaint.type = paint.type;
16068
16079
  return getPaint;
16069
16080
  };
@@ -16072,20 +16083,28 @@ function preparePaint(paint, defaultPaint, getPaintFunctions) {
16072
16083
  }
16073
16084
  else if (isPropertiesPaint(paint)) {
16074
16085
  return (feature) => {
16075
- return preparePaint(createPropertiesPaint(paint)(feature), defaultPaint, getPaintFunctions);
16086
+ return preparePaint({
16087
+ paint: createPropertiesPaint(paint)(feature),
16088
+ defaultPaint,
16089
+ getPaintFunctions,
16090
+ });
16076
16091
  };
16077
16092
  }
16078
16093
  else if (paint.type === 'get-paint') {
16079
16094
  const getPaint = updatePaintOptionFromCallback(paint, getPaintFunctions);
16080
16095
  if (getPaint) {
16081
- newPaint = preparePaint(getPaint, defaultPaint, getPaintFunctions);
16096
+ newPaint = preparePaint({
16097
+ paint: getPaint,
16098
+ defaultPaint,
16099
+ getPaintFunctions,
16100
+ });
16082
16101
  }
16083
16102
  }
16084
16103
  else if (paint.type === 'icon') {
16085
16104
  return paint;
16086
16105
  }
16087
16106
  else {
16088
- newPaint = expressionCallback(paint, defaultPaint, getPaintFunctions);
16107
+ newPaint = expressionCallback({ paint, defaultPaint });
16089
16108
  }
16090
16109
  if (isPaintCallback(newPaint)) {
16091
16110
  return newPaint;
@@ -17693,10 +17712,18 @@ class WebMapLayers extends WebMapMain {
17693
17712
  };
17694
17713
  if (!options.nativePaint) {
17695
17714
  if (this.options.paint) {
17696
- options.paint = preparePaint(options.paint || {}, this.options.paint, this.getPaintFunctions);
17715
+ options.paint = preparePaint({
17716
+ paint: options.paint || {},
17717
+ defaultPaint: this.options.paint,
17718
+ getPaintFunctions: this.getPaintFunctions,
17719
+ });
17697
17720
  }
17698
17721
  if (options.selectedPaint && this.options.selectedPaint) {
17699
- options.selectedPaint = preparePaint(options.selectedPaint, this.options.selectedPaint, this.getPaintFunctions);
17722
+ options.selectedPaint = preparePaint({
17723
+ paint: options.selectedPaint,
17724
+ defaultPaint: this.options.selectedPaint,
17725
+ getPaintFunctions: this.getPaintFunctions,
17726
+ });
17700
17727
  }
17701
17728
  }
17702
17729
  }
@@ -22060,21 +22087,23 @@ function insertSvg(svg) {
22060
22087
  return oDOM.documentElement;
22061
22088
  }
22062
22089
  function getIcon(opt = {}) {
22063
- var _a, _b, _c, _d;
22090
+ var _a, _b, _c, _d, _e;
22064
22091
  // default values
22065
22092
  const shape = (_a = opt.shape) !== null && _a !== void 0 ? _a : 'circle';
22066
22093
  const color = (_b = opt.color) !== null && _b !== void 0 ? _b : 'blue';
22067
22094
  const strokeColor = (_c = opt.strokeColor) !== null && _c !== void 0 ? _c : 'white';
22068
22095
  const size = (_d = opt.size) !== null && _d !== void 0 ? _d : 12;
22096
+ const rotate = (_e = opt.rotate) !== null && _e !== void 0 ? _e : 0;
22069
22097
  const anchor = size / 2;
22070
22098
  const defSize = 12;
22071
- const stroke = typeof opt.stroke === 'number' ? opt.stroke : STROKE;
22099
+ const stroke = opt.stroke !== undefined ? Number(opt.stroke) : STROKE;
22072
22100
  const scale = size / defSize;
22073
22101
  const pathAlias = opt.p || svgPath[shape] || 'circle';
22074
22102
  const path = typeof pathAlias === 'string' ? pathAlias : pathAlias(opt);
22075
22103
  const svg = insertSvg(opt.svg || generateSvg(size, size, stroke * scale, path));
22076
22104
  const fistChild = svg.firstChild;
22077
- const transform = `scale(${scale})`;
22105
+ const scaledAnchor = defSize / 2;
22106
+ const transform = `scale(${scale}) rotate(${rotate}, ${scaledAnchor}, ${scaledAnchor})`;
22078
22107
  fistChild.setAttribute('fill', color);
22079
22108
  if (stroke) {
22080
22109
  fistChild.setAttribute('stroke', strokeColor);