@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.
@@ -402,6 +402,18 @@ class GetFeaturesInAreaQuery extends PostboyCallbackMessage {
402
402
  }
403
403
  GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
404
404
 
405
+ class FilterFeaturesInAreaExecutor extends PostboyExecutor {
406
+ constructor(area, features) {
407
+ super();
408
+ this.area = area;
409
+ this.features = features;
410
+ }
411
+ get id() {
412
+ return FilterFeaturesInAreaExecutor.ID;
413
+ }
414
+ }
415
+ FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
416
+
405
417
  class AddLayerCommand extends PostboyGenericMessage {
406
418
  constructor(layer) {
407
419
  super();
@@ -534,18 +546,6 @@ class FeatureService {
534
546
  }
535
547
  }
536
548
 
537
- class FilterFeaturesInAreaExecutor extends PostboyExecutor {
538
- constructor(area, features) {
539
- super();
540
- this.area = area;
541
- this.features = features;
542
- }
543
- get id() {
544
- return FilterFeaturesInAreaExecutor.ID;
545
- }
546
- }
547
- FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
548
-
549
549
  class GenerateDrawExecutor extends PostboyExecutor {
550
550
  constructor(layer, style, type) {
551
551
  super();
@@ -1112,6 +1112,13 @@ class TileLayerSettings {
1112
1112
  * @default 'EPSG:3857'
1113
1113
  */
1114
1114
  this.projection = 'EPSG:3857';
1115
+ /**
1116
+ * Additional headers that should be added to each tile request
1117
+ *
1118
+ * @type {Record<string, string>}
1119
+ * @default An empty array
1120
+ */
1121
+ this.requestHeaders = null;
1115
1122
  }
1116
1123
  /**
1117
1124
  * Creates a copy of the given tile layer settings.
@@ -1126,6 +1133,7 @@ class TileLayerSettings {
1126
1133
  result.projection = model.projection;
1127
1134
  result.opacity = model.opacity;
1128
1135
  result.url = model.url;
1136
+ result.requestHeaders = model.requestHeaders;
1129
1137
  return result;
1130
1138
  }
1131
1139
  /**
@@ -1137,6 +1145,15 @@ class TileLayerSettings {
1137
1145
  setUrl(url) {
1138
1146
  return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { url }));
1139
1147
  }
1148
+ /**
1149
+ * Sets the requestHeaders of the TileLayerSettings object.
1150
+ *
1151
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
1152
+ * @return {TileLayerSettings} - The updated TileLayerSettings object.
1153
+ */
1154
+ setRequestHeaders(requestHeaders) {
1155
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { requestHeaders }));
1156
+ }
1140
1157
  /**
1141
1158
  * Sets the maximum zoom level for the tile layer.
1142
1159
  *
@@ -1190,6 +1207,8 @@ class TileLayerSettings {
1190
1207
  return false;
1191
1208
  if (this.opacity !== model.opacity)
1192
1209
  return false;
1210
+ if (this.requestHeaders !== model.requestHeaders)
1211
+ return false;
1193
1212
  return true;
1194
1213
  }
1195
1214
  }
@@ -1203,6 +1222,9 @@ class TileLayerFactory {
1203
1222
  projection: get(settings.projection),
1204
1223
  tileUrlFunction: this.getTileFunc(settings),
1205
1224
  crossOrigin: 'Anonymous',
1225
+ tileLoadFunction: !!settings.requestHeaders
1226
+ ? (tile, src) => this.tileLoader(tile, src, settings.requestHeaders)
1227
+ : undefined,
1206
1228
  });
1207
1229
  return new TileLayer({ source, opacity: settings.opacity });
1208
1230
  }
@@ -1219,6 +1241,21 @@ class TileLayerFactory {
1219
1241
  .replace('{y}', String(bound - ((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.y) || y) - 1));
1220
1242
  };
1221
1243
  }
1244
+ tileLoader(tile, src, headers) {
1245
+ const client = new XMLHttpRequest();
1246
+ client.open('GET', src);
1247
+ client.responseType = 'arraybuffer';
1248
+ Object.keys(headers).forEach((k) => client.setRequestHeader(k, headers[k]));
1249
+ client.onload = function () {
1250
+ if (this.response !== undefined) {
1251
+ const arrayBufferView = new Uint8Array(this.response);
1252
+ const blob = new Blob([arrayBufferView], { type: 'image/png' });
1253
+ const urlCreator = window.URL || window.webkitURL;
1254
+ tile.getImage().src = urlCreator.createObjectURL(blob);
1255
+ }
1256
+ };
1257
+ client.send();
1258
+ }
1222
1259
  getNormalizedCoord(coord, zoom) {
1223
1260
  const y = coord.y;
1224
1261
  let x = coord.x;
@@ -2483,5 +2520,5 @@ class StringifyFeatureHelper {
2483
2520
  * Generated bundle index. Do not edit.
2484
2521
  */
2485
2522
 
2486
- 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 };
2523
+ 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 };
2487
2524
  //# sourceMappingURL=maps-components.mjs.map