@nextgis/ngw-map 1.18.3 → 1.18.6

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.3; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.18.6; author: NextGIS */
2
2
  import { EventEmitter } from 'events';
3
3
  import CancelablePromise from '@nextgis/cancelable-promise';
4
4
  import { deepmerge, deprecatedWarn, defined, isObject, getIdentifyRadius } from '@nextgis/utils';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.18.3; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.18.6; author: NextGIS */
2
2
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -5511,10 +5511,11 @@ var NgwMap = (function (exports) {
5511
5511
  */
5512
5512
  NgwConnector.prototype.apiRequest = function (name, params_, requestOptions) {
5513
5513
  var _this = this;
5514
- var _a;
5514
+ var _a, _b;
5515
5515
  if (params_ === void 0) { params_ = {}; }
5516
5516
  if (requestOptions === void 0) { requestOptions = {}; }
5517
5517
  var method = requestOptions.method, headers = requestOptions.headers, withCredentials = requestOptions.withCredentials, responseType = requestOptions.responseType;
5518
+ params_ = (_a = requestOptions.params) !== null && _a !== void 0 ? _a : params_;
5518
5519
  var params = objectRemoveEmpty(params_);
5519
5520
  var makeApiRequest = function () {
5520
5521
  return apiRequest({ name: name, params: params, requestOptions: requestOptions, connector: _this });
@@ -5526,7 +5527,7 @@ var NgwMap = (function (exports) {
5526
5527
  withCredentials: withCredentials,
5527
5528
  responseType: responseType,
5528
5529
  baseUrl: this.options.baseUrl,
5529
- userId: (_a = this.user) === null || _a === void 0 ? void 0 : _a.id,
5530
+ userId: (_b = this.user) === null || _b === void 0 ? void 0 : _b.id,
5530
5531
  })));
5531
5532
  }
5532
5533
  return makeApiRequest();
@@ -8930,11 +8931,12 @@ var NgwMap = (function (exports) {
8930
8931
  minus: '<path d="m12 7.5v-3h-12v3z"/>',
8931
8932
  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"/>',
8932
8933
  };
8934
+ var VIEW_BOX = 12;
8933
8935
  var STROKE = 0.8;
8934
- function generateSvg(width, height, stroke, content) {
8935
- if (stroke === void 0) { stroke = 0; }
8936
+ function generateSvg(_a) {
8937
+ var width = _a.width, height = _a.height, _b = _a.stroke, stroke = _b === void 0 ? 0 : _b, content = _a.content;
8936
8938
  var s = stroke / 2;
8937
- 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>");
8939
+ 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>");
8938
8940
  return svg;
8939
8941
  }
8940
8942
  function insertSvg(svg) {
@@ -8942,37 +8944,46 @@ var NgwMap = (function (exports) {
8942
8944
  var oDOM = oParser.parseFromString(svg, 'image/svg+xml');
8943
8945
  return oDOM.documentElement;
8944
8946
  }
8947
+ /**
8948
+ * Retrieves an icon with the provided options.
8949
+ * @function
8950
+ * @param {IconOptions} [opt={}] - Options for the icon.
8951
+ * @returns {IconPaint} Icon paint object.
8952
+ */
8945
8953
  function getIcon(opt) {
8946
- var _a, _b, _c, _d, _e;
8954
+ var _a, _b, _c, _d, _e, _f;
8947
8955
  if (opt === void 0) { opt = {}; }
8948
- // default values
8956
+ // Default values
8949
8957
  var shape = (_a = opt.shape) !== null && _a !== void 0 ? _a : 'circle';
8950
8958
  var color = (_b = opt.color) !== null && _b !== void 0 ? _b : 'blue';
8951
8959
  var strokeColor = (_c = opt.strokeColor) !== null && _c !== void 0 ? _c : 'white';
8952
- var size = (_d = opt.size) !== null && _d !== void 0 ? _d : 12;
8960
+ var size = (_d = opt.size) !== null && _d !== void 0 ? _d : VIEW_BOX;
8953
8961
  var rotate = (_e = opt.rotate) !== null && _e !== void 0 ? _e : 0;
8954
- var anchor = size / 2;
8955
- var defSize = 12;
8962
+ var anchor = (_f = opt.anchor) !== null && _f !== void 0 ? _f : [size / 2, size / 2];
8956
8963
  var stroke = opt.stroke !== undefined ? Number(opt.stroke) : STROKE;
8957
- var scale = size / defSize;
8958
8964
  var pathAlias = opt.p || svgPath[shape] || 'circle';
8959
8965
  var path = typeof pathAlias === 'string' ? pathAlias : pathAlias(opt);
8960
- var svg = insertSvg(opt.svg || generateSvg(size, size, stroke * scale, path));
8961
- var fistChild = svg.firstChild;
8962
- var scaledAnchor = defSize / 2;
8963
- var transform = "scale(".concat(scale, ") rotate(").concat(rotate, ", ").concat(scaledAnchor, ", ").concat(scaledAnchor, ")");
8964
- fistChild.setAttribute('fill', color);
8966
+ var svg = insertSvg(opt.svg ||
8967
+ generateSvg({
8968
+ width: size,
8969
+ height: size,
8970
+ stroke: stroke,
8971
+ content: path,
8972
+ }));
8973
+ svg.setAttribute('width', String(size));
8974
+ svg.setAttribute('height', String(size));
8975
+ svg.setAttribute('fill', color);
8965
8976
  if (stroke) {
8966
- fistChild.setAttribute('stroke', strokeColor);
8967
- fistChild.setAttribute('stroke-width', String(stroke));
8977
+ svg.setAttribute('stroke', strokeColor);
8978
+ svg.setAttribute('stroke-width', String(stroke));
8968
8979
  }
8969
- fistChild.setAttribute('transform', transform);
8970
8980
  var s = new XMLSerializer();
8971
8981
  return {
8972
8982
  type: 'icon',
8973
8983
  iconSize: [size, size],
8974
- iconAnchor: [anchor, anchor],
8984
+ iconAnchor: anchor,
8975
8985
  html: s.serializeToString(svg),
8986
+ rotate: rotate,
8976
8987
  svg: svg,
8977
8988
  };
8978
8989
  }