@artstesh/maps 4.1.11 → 4.1.13

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.
@@ -401,6 +401,18 @@ class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
401
401
  }
402
402
  GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
403
403
 
404
+ class FilterFeaturesInAreaExecutor extends PostboyExecutor {
405
+ constructor(area, features) {
406
+ super();
407
+ this.area = area;
408
+ this.features = features;
409
+ }
410
+ get id() {
411
+ return FilterFeaturesInAreaExecutor.ID;
412
+ }
413
+ }
414
+ FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
415
+
404
416
  class AddLayerCommand extends PostboyGenericMessage {
405
417
  constructor(layer) {
406
418
  super();
@@ -533,18 +545,6 @@ class FeatureService {
533
545
  }
534
546
  }
535
547
 
536
- class FilterFeaturesInAreaExecutor extends PostboyExecutor {
537
- constructor(area, features) {
538
- super();
539
- this.area = area;
540
- this.features = features;
541
- }
542
- get id() {
543
- return FilterFeaturesInAreaExecutor.ID;
544
- }
545
- }
546
- FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
547
-
548
548
  class GenerateDrawExecutor extends PostboyExecutor {
549
549
  constructor(layer, style, type) {
550
550
  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, 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 };
2497
+ export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, 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