@artstesh/maps 6.0.3 → 6.0.5

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.
@@ -419,6 +419,20 @@ class GetMapPositionExecutor extends PostboyExecutor {
419
419
  }
420
420
  }
421
421
 
422
+ class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
423
+ area;
424
+ ignore;
425
+ static ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
426
+ constructor(area, ignore = new Set()) {
427
+ super();
428
+ this.area = area;
429
+ this.ignore = ignore;
430
+ }
431
+ get id() {
432
+ return GetFeaturesInAreaQuery.ID;
433
+ }
434
+ }
435
+
422
436
  class AddLayerCommand extends PostboyGenericMessage {
423
437
  layer;
424
438
  static ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
@@ -560,20 +574,6 @@ class FeatureService {
560
574
  }
561
575
  }
562
576
 
563
- class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
564
- area;
565
- ignore;
566
- static ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
567
- constructor(area, ignore = new Set()) {
568
- super();
569
- this.area = area;
570
- this.ignore = ignore;
571
- }
572
- get id() {
573
- return GetFeaturesInAreaQuery.ID;
574
- }
575
- }
576
-
577
577
  class FilterFeaturesInAreaExecutor extends PostboyExecutor {
578
578
  area;
579
579
  features;
@@ -1163,6 +1163,13 @@ class TileLayerSettings {
1163
1163
  * @default 'EPSG:3857'
1164
1164
  */
1165
1165
  projection = 'EPSG:3857';
1166
+ /**
1167
+ * Additional headers that should be added to each tile request
1168
+ *
1169
+ * @type {Record<string, string>}
1170
+ * @default An empty array
1171
+ */
1172
+ requestHeaders = null;
1166
1173
  /**
1167
1174
  * Creates a copy of the given tile layer settings.
1168
1175
  *
@@ -1176,6 +1183,7 @@ class TileLayerSettings {
1176
1183
  result.projection = model.projection;
1177
1184
  result.opacity = model.opacity;
1178
1185
  result.url = model.url;
1186
+ result.requestHeaders = model.requestHeaders;
1179
1187
  return result;
1180
1188
  }
1181
1189
  /**
@@ -1187,6 +1195,15 @@ class TileLayerSettings {
1187
1195
  setUrl(url) {
1188
1196
  return TileLayerSettings.copy({ ...this, url });
1189
1197
  }
1198
+ /**
1199
+ * Sets the requestHeaders of the TileLayerSettings object.
1200
+ *
1201
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
1202
+ * @return {TileLayerSettings} - The updated TileLayerSettings object.
1203
+ */
1204
+ setRequestHeaders(requestHeaders) {
1205
+ return TileLayerSettings.copy({ ...this, requestHeaders });
1206
+ }
1190
1207
  /**
1191
1208
  * Sets the maximum zoom level for the tile layer.
1192
1209
  *
@@ -1240,6 +1257,8 @@ class TileLayerSettings {
1240
1257
  return false;
1241
1258
  if (this.opacity !== model.opacity)
1242
1259
  return false;
1260
+ if (this.requestHeaders !== model.requestHeaders)
1261
+ return false;
1243
1262
  return true;
1244
1263
  }
1245
1264
  }
@@ -1253,6 +1272,9 @@ class TileLayerFactory {
1253
1272
  projection: get(settings.projection),
1254
1273
  tileUrlFunction: this.getTileFunc(settings),
1255
1274
  crossOrigin: 'Anonymous',
1275
+ tileLoadFunction: !!settings.requestHeaders
1276
+ ? (tile, src) => this.tileLoader(tile, src, settings.requestHeaders)
1277
+ : undefined,
1256
1278
  });
1257
1279
  return new TileLayer({ source, opacity: settings.opacity });
1258
1280
  }
@@ -1269,6 +1291,21 @@ class TileLayerFactory {
1269
1291
  .replace('{y}', String(bound - (normalizedCoord?.y || y) - 1));
1270
1292
  };
1271
1293
  }
1294
+ tileLoader(tile, src, headers) {
1295
+ const client = new XMLHttpRequest();
1296
+ client.open('GET', src);
1297
+ client.responseType = 'arraybuffer';
1298
+ Object.keys(headers).forEach((k) => client.setRequestHeader(k, headers[k]));
1299
+ client.onload = function () {
1300
+ if (this.response !== undefined) {
1301
+ const arrayBufferView = new Uint8Array(this.response);
1302
+ const blob = new Blob([arrayBufferView], { type: 'image/png' });
1303
+ const urlCreator = window.URL || window.webkitURL;
1304
+ tile.getImage().src = urlCreator.createObjectURL(blob);
1305
+ }
1306
+ };
1307
+ client.send();
1308
+ }
1272
1309
  getNormalizedCoord(coord, zoom) {
1273
1310
  const y = coord.y;
1274
1311
  let x = coord.x;
@@ -2553,5 +2590,5 @@ class StringifyFeatureHelper {
2553
2590
  * Generated bundle index. Do not edit.
2554
2591
  */
2555
2592
 
2556
- export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FitToPolygonsCommand, GetMapPositionExecutor, MapClickEvent, MapControl, MapControlZoomComponent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
2593
+ export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetMapPositionExecutor, MapClickEvent, MapControl, MapControlZoomComponent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
2557
2594
  //# sourceMappingURL=maps-components.mjs.map