@nextgis/ngw-map 4.0.0 → 4.0.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: 4.0.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 4.0.2; author: NextGIS */
2
2
  import { getIcon } from '@nextgis/icons';
3
3
  import NgwConnector from '@nextgis/ngw-connector';
4
4
  import { NgwKit, fetchNgwLayerItem, fetchNgwLayerItems, fetchNgwLayerFeature, fetchNgwLayerFeatureCollection, fetchIdentifyItem, fetchIdentifyGeoJson, createNgwLayerAdapter, fetchNgwExtent, sendIdentifyRequest, getCompanyLogo, getIdentifyItems, createIdentifyItem } from '@nextgis/ngw-kit';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 4.0.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 4.0.2; author: NextGIS */
2
2
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -352,8 +352,14 @@ var NgwMap = (function (exports) {
352
352
  return url.replace(/([^:]\/)\/+/g, "$1");
353
353
  }
354
354
  function updateUrlParams(urlStr, params) {
355
- const url = new URL(urlStr);
356
- const searchParams = new URLSearchParams(url.search);
355
+ const hashIndex = urlStr.indexOf("#");
356
+ const hash = hashIndex === -1 ? "" : urlStr.slice(hashIndex);
357
+ const url = hashIndex === -1 ? urlStr : urlStr.slice(0, hashIndex);
358
+ const queryIndex = url.indexOf("?");
359
+ const baseUrl = queryIndex === -1 ? url : url.slice(0, queryIndex);
360
+ const searchParams = new URLSearchParams(
361
+ queryIndex === -1 ? "" : url.slice(queryIndex + 1)
362
+ );
357
363
  Object.entries(params).forEach(([key, value]) => {
358
364
  if (value === void 0) {
359
365
  searchParams.delete(key);
@@ -363,7 +369,7 @@ var NgwMap = (function (exports) {
363
369
  });
364
370
  searchParams.set("timestamp", String((/* @__PURE__ */ new Date()).getTime()));
365
371
  const newSearch = [...searchParams.entries()].map(([key, value]) => `${key}=${value}`).join("&");
366
- return `${url.origin}${url.pathname}?${newSearch}`;
372
+ return `${baseUrl}?${newSearch}${hash}`;
367
373
  }
368
374
 
369
375
  const templateRe = /\{ *([\w_-]+) *\}/g;
@@ -1080,7 +1086,7 @@ var NgwMap = (function (exports) {
1080
1086
  }
1081
1087
 
1082
1088
  var pkg = {
1083
- version: "4.0.0"};
1089
+ version: "4.0.2"};
1084
1090
 
1085
1091
  class AbortError extends Error {
1086
1092
  constructor(message = "AbortError") {
@@ -4882,7 +4888,7 @@ var NgwMap = (function (exports) {
4882
4888
  return webmap.bookmark_resource.id;
4883
4889
  }
4884
4890
  }
4885
- fetchBookmarks(options) {
4891
+ fetchBookmarks(options = {}) {
4886
4892
  const bookmarkResId = this.getBookmarksResourceId();
4887
4893
  const connector = this.options.connector;
4888
4894
  if (bookmarkResId) {
@@ -5543,9 +5549,9 @@ var NgwMap = (function (exports) {
5543
5549
  item
5544
5550
  }) {
5545
5551
  if (item.basemap_layer) {
5546
- const qms = item.basemap_layer.qms;
5547
- const url = item.basemap_layer.url;
5548
- if (qms) {
5552
+ const basemap = item.basemap_layer;
5553
+ const { qms, url } = basemap;
5554
+ if (qms && typeof qms === "string") {
5549
5555
  const qms_ = JSON.parse(qms);
5550
5556
  const adapter = Promise.resolve(
5551
5557
  createQmsAdapter(webMap, {
@@ -5558,10 +5564,19 @@ var NgwMap = (function (exports) {
5558
5564
  const TileAdapter = webMap.mapAdapter.layerAdapters.TILE;
5559
5565
  if (TileAdapter) {
5560
5566
  class BasemapTileAdapter extends TileAdapter {
5567
+ constructor(map, options) {
5568
+ super(map, __spreadProps$a(__spreadValues$f({}, options), { baselayer: true, order: 0 }));
5569
+ }
5561
5570
  addLayer(opt) {
5562
5571
  return __async$g(this, null, function* () {
5572
+ var _a, _b, _c;
5563
5573
  if (url) {
5564
- return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$a(__spreadValues$f({}, opt), { url }));
5574
+ return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$a(__spreadValues$f({}, opt), {
5575
+ url,
5576
+ minZoom: (_a = basemap.z_min) != null ? _a : opt.minZoom,
5577
+ maxZoom: (_b = basemap.z_max) != null ? _b : opt.maxZoom,
5578
+ attribution: (_c = basemap.copyright_text) != null ? _c : opt.attribution
5579
+ }));
5565
5580
  }
5566
5581
  });
5567
5582
  }