@artstesh/maps 4.1.10 → 4.1.12

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.
@@ -389,6 +389,18 @@ class GetMapPositionExecutor extends PostboyExecutor {
389
389
  }
390
390
  GetMapPositionExecutor.ID = '52c95689-d09b-4082-ba58-9183ea96a213';
391
391
 
392
+ class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
393
+ constructor(area, ignore = new Set()) {
394
+ super();
395
+ this.area = area;
396
+ this.ignore = ignore;
397
+ }
398
+ get id() {
399
+ return GetFeaturesInAreaQuery.ID;
400
+ }
401
+ }
402
+ GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
403
+
392
404
  class AddLayerCommand extends PostboyGenericMessage {
393
405
  constructor(layer) {
394
406
  super();
@@ -521,18 +533,6 @@ class FeatureService {
521
533
  }
522
534
  }
523
535
 
524
- class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
525
- constructor(area, ignore = new Set()) {
526
- super();
527
- this.area = area;
528
- this.ignore = ignore;
529
- }
530
- get id() {
531
- return GetFeaturesInAreaQuery.ID;
532
- }
533
- }
534
- GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
535
-
536
536
  class FilterFeaturesInAreaExecutor extends PostboyExecutor {
537
537
  constructor(area, features) {
538
538
  super();
@@ -1098,6 +1098,13 @@ class TileLayerSettings {
1098
1098
  * @default 'EPSG:3857'
1099
1099
  */
1100
1100
  this.projection = 'EPSG:3857';
1101
+ /**
1102
+ * Additional headers that should be added to each tile request
1103
+ *
1104
+ * @type {Record<string, string>}
1105
+ * @default An empty array
1106
+ */
1107
+ this.requestHeaders = null;
1101
1108
  }
1102
1109
  /**
1103
1110
  * Creates a copy of the given tile layer settings.
@@ -1112,6 +1119,7 @@ class TileLayerSettings {
1112
1119
  result.projection = model.projection;
1113
1120
  result.opacity = model.opacity;
1114
1121
  result.url = model.url;
1122
+ result.requestHeaders = model.requestHeaders;
1115
1123
  return result;
1116
1124
  }
1117
1125
  /**
@@ -1123,6 +1131,15 @@ class TileLayerSettings {
1123
1131
  setUrl(url) {
1124
1132
  return TileLayerSettings.copy({ ...this, url });
1125
1133
  }
1134
+ /**
1135
+ * Sets the requestHeaders of the TileLayerSettings object.
1136
+ *
1137
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
1138
+ * @return {TileLayerSettings} - The updated TileLayerSettings object.
1139
+ */
1140
+ setRequestHeaders(requestHeaders) {
1141
+ return TileLayerSettings.copy({ ...this, requestHeaders });
1142
+ }
1126
1143
  /**
1127
1144
  * Sets the maximum zoom level for the tile layer.
1128
1145
  *
@@ -1176,6 +1193,8 @@ class TileLayerSettings {
1176
1193
  return false;
1177
1194
  if (this.opacity !== model.opacity)
1178
1195
  return false;
1196
+ if (this.requestHeaders !== model.requestHeaders)
1197
+ return false;
1179
1198
  return true;
1180
1199
  }
1181
1200
  }
@@ -1189,6 +1208,9 @@ class TileLayerFactory {
1189
1208
  projection: get(settings.projection),
1190
1209
  tileUrlFunction: this.getTileFunc(settings),
1191
1210
  crossOrigin: 'Anonymous',
1211
+ tileLoadFunction: !!settings.requestHeaders
1212
+ ? (tile, src) => this.tileLoader(tile, src, settings.requestHeaders)
1213
+ : undefined,
1192
1214
  });
1193
1215
  return new TileLayer({ source, opacity: settings.opacity });
1194
1216
  }
@@ -1205,6 +1227,21 @@ class TileLayerFactory {
1205
1227
  .replace('{y}', String(bound - (normalizedCoord?.y || y) - 1));
1206
1228
  };
1207
1229
  }
1230
+ tileLoader(tile, src, headers) {
1231
+ const client = new XMLHttpRequest();
1232
+ client.open('GET', src);
1233
+ client.responseType = 'arraybuffer';
1234
+ Object.keys(headers).forEach((k) => client.setRequestHeader(k, headers[k]));
1235
+ client.onload = function () {
1236
+ if (this.response !== undefined) {
1237
+ const arrayBufferView = new Uint8Array(this.response);
1238
+ const blob = new Blob([arrayBufferView], { type: 'image/png' });
1239
+ const urlCreator = window.URL || window.webkitURL;
1240
+ tile.getImage().src = urlCreator.createObjectURL(blob);
1241
+ }
1242
+ };
1243
+ client.send();
1244
+ }
1208
1245
  getNormalizedCoord(coord, zoom) {
1209
1246
  const y = coord.y;
1210
1247
  let x = coord.x;
@@ -2457,5 +2494,5 @@ class StringifyFeatureHelper {
2457
2494
  * Generated bundle index. Do not edit.
2458
2495
  */
2459
2496
 
2460
- 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 };
2497
+ 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 };
2461
2498
  //# sourceMappingURL=maps-components-src-map.mjs.map