@nextgis/ngw-map 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-map; version: 1.18.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.18.2; author: NextGIS */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.18.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.18.2; author: NextGIS */
2
2
  var events = {exports: {}};
3
3
 
4
4
  var R = typeof Reflect === 'object' ? Reflect : null;
@@ -1947,32 +1947,43 @@ function createPropertiesPaint(propertiesPaint) {
1947
1947
  return mask;
1948
1948
  };
1949
1949
  }
1950
- function expressionCallback(paint, defaultPaint, getPaintFunctions) {
1950
+ function expressionCallback({ paint, defaultPaint, }) {
1951
1951
  const expressionCallback = createExpressionCallback(paint);
1952
1952
  if (expressionCallback) {
1953
1953
  const expressionPaintCb = (feature) => {
1954
- return preparePaint(expressionCallback(feature), defaultPaint, getPaintFunctions);
1954
+ return preparePaint({
1955
+ paint: expressionCallback(feature),
1956
+ defaultPaint,
1957
+ });
1955
1958
  };
1956
- expressionPaintCb.paint = paint;
1959
+ expressionPaintCb.paint = finalizePaint({ paint, defaultPaint });
1957
1960
  return expressionPaintCb;
1958
1961
  }
1962
+ return finalizePaint({ paint, defaultPaint });
1963
+ }
1964
+ function finalizePaint({ paint, defaultPaint }) {
1965
+ var _a;
1959
1966
  let newPaint = { ...defaultPaint };
1960
1967
  newPaint = { ...newPaint, ...paint };
1961
- newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
1968
+ newPaint.fill = (_a = newPaint.fill) !== null && _a !== void 0 ? _a : true;
1962
1969
  newPaint.stroke =
1963
1970
  newPaint.stroke !== undefined
1964
1971
  ? newPaint.stroke
1965
1972
  : !newPaint.fill || !!(newPaint.strokeColor || newPaint.strokeOpacity);
1966
1973
  return newPaint;
1967
1974
  }
1968
- function preparePaint(paint, defaultPaint, getPaintFunctions) {
1975
+ function preparePaint({ paint, defaultPaint, getPaintFunctions, }) {
1969
1976
  if (!paint) {
1970
1977
  throw new Error('paint is empty');
1971
1978
  }
1972
1979
  let newPaint = { ...defaultPaint };
1973
1980
  if (isPaintCallback(paint)) {
1974
1981
  const getPaintFunction = (feature) => {
1975
- const getPaint = preparePaint(paint(feature), defaultPaint, getPaintFunctions);
1982
+ const getPaint = preparePaint({
1983
+ paint: paint(feature),
1984
+ defaultPaint,
1985
+ getPaintFunctions,
1986
+ });
1976
1987
  getPaint.type = paint.type;
1977
1988
  return getPaint;
1978
1989
  };
@@ -1981,20 +1992,28 @@ function preparePaint(paint, defaultPaint, getPaintFunctions) {
1981
1992
  }
1982
1993
  else if (isPropertiesPaint(paint)) {
1983
1994
  return (feature) => {
1984
- return preparePaint(createPropertiesPaint(paint)(feature), defaultPaint, getPaintFunctions);
1995
+ return preparePaint({
1996
+ paint: createPropertiesPaint(paint)(feature),
1997
+ defaultPaint,
1998
+ getPaintFunctions,
1999
+ });
1985
2000
  };
1986
2001
  }
1987
2002
  else if (paint.type === 'get-paint') {
1988
2003
  const getPaint = updatePaintOptionFromCallback(paint, getPaintFunctions);
1989
2004
  if (getPaint) {
1990
- newPaint = preparePaint(getPaint, defaultPaint, getPaintFunctions);
2005
+ newPaint = preparePaint({
2006
+ paint: getPaint,
2007
+ defaultPaint,
2008
+ getPaintFunctions,
2009
+ });
1991
2010
  }
1992
2011
  }
1993
2012
  else if (paint.type === 'icon') {
1994
2013
  return paint;
1995
2014
  }
1996
2015
  else {
1997
- newPaint = expressionCallback(paint, defaultPaint, getPaintFunctions);
2016
+ newPaint = expressionCallback({ paint, defaultPaint });
1998
2017
  }
1999
2018
  if (isPaintCallback(newPaint)) {
2000
2019
  return newPaint;
@@ -3602,10 +3621,18 @@ class WebMapLayers extends WebMapMain {
3602
3621
  };
3603
3622
  if (!options.nativePaint) {
3604
3623
  if (this.options.paint) {
3605
- options.paint = preparePaint(options.paint || {}, this.options.paint, this.getPaintFunctions);
3624
+ options.paint = preparePaint({
3625
+ paint: options.paint || {},
3626
+ defaultPaint: this.options.paint,
3627
+ getPaintFunctions: this.getPaintFunctions,
3628
+ });
3606
3629
  }
3607
3630
  if (options.selectedPaint && this.options.selectedPaint) {
3608
- options.selectedPaint = preparePaint(options.selectedPaint, this.options.selectedPaint, this.getPaintFunctions);
3631
+ options.selectedPaint = preparePaint({
3632
+ paint: options.selectedPaint,
3633
+ defaultPaint: this.options.selectedPaint,
3634
+ getPaintFunctions: this.getPaintFunctions,
3635
+ });
3609
3636
  }
3610
3637
  }
3611
3638
  }
@@ -8034,21 +8061,23 @@ function insertSvg(svg) {
8034
8061
  return oDOM.documentElement;
8035
8062
  }
8036
8063
  function getIcon(opt = {}) {
8037
- var _a, _b, _c, _d;
8064
+ var _a, _b, _c, _d, _e;
8038
8065
  // default values
8039
8066
  const shape = (_a = opt.shape) !== null && _a !== void 0 ? _a : 'circle';
8040
8067
  const color = (_b = opt.color) !== null && _b !== void 0 ? _b : 'blue';
8041
8068
  const strokeColor = (_c = opt.strokeColor) !== null && _c !== void 0 ? _c : 'white';
8042
8069
  const size = (_d = opt.size) !== null && _d !== void 0 ? _d : 12;
8070
+ const rotate = (_e = opt.rotate) !== null && _e !== void 0 ? _e : 0;
8043
8071
  const anchor = size / 2;
8044
8072
  const defSize = 12;
8045
- const stroke = typeof opt.stroke === 'number' ? opt.stroke : STROKE;
8073
+ const stroke = opt.stroke !== undefined ? Number(opt.stroke) : STROKE;
8046
8074
  const scale = size / defSize;
8047
8075
  const pathAlias = opt.p || svgPath[shape] || 'circle';
8048
8076
  const path = typeof pathAlias === 'string' ? pathAlias : pathAlias(opt);
8049
8077
  const svg = insertSvg(opt.svg || generateSvg(size, size, stroke * scale, path));
8050
8078
  const fistChild = svg.firstChild;
8051
- const transform = `scale(${scale})`;
8079
+ const scaledAnchor = defSize / 2;
8080
+ const transform = `scale(${scale}) rotate(${rotate}, ${scaledAnchor}, ${scaledAnchor})`;
8052
8081
  fistChild.setAttribute('fill', color);
8053
8082
  if (stroke) {
8054
8083
  fistChild.setAttribute('stroke', strokeColor);