@artstesh/maps 1.1.10 → 1.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.
package/README.md CHANGED
@@ -1,13 +1,11 @@
1
- # @artstesh/maps
2
-
3
- Let's map a feature ;)
4
-
5
- ### Description of the project
6
-
7
- The main purpose of the project is to make easier the process of using of [openlayers library](https://openlayers.org/) in Angular projects.
8
-
9
- It's just the first, initial version of the library, that gonna become much more functional in a few weeks.
10
-
11
- ### License
12
-
13
- This project is licensed under the MIT License
1
+ # @artstesh/maps
2
+
3
+ Let's map a feature ;)
4
+
5
+ ### Description of the project
6
+
7
+ The main purpose of the project is to make easier the process of using of [openlayers library](https://openlayers.org/) in Angular projects.
8
+
9
+ ### License
10
+
11
+ This project is licensed under the MIT License
@@ -1018,6 +1018,25 @@
1018
1018
  }(postboy.PostboyCallbackMessage));
1019
1019
  GetFeaturesInAreaQuery.ID = 'efcf4271-a07a-40e0-9f02-d4dade40b8ac';
1020
1020
 
1021
+ var FilterFeaturesInAreaExecutor = /** @class */ (function (_super) {
1022
+ __extends(FilterFeaturesInAreaExecutor, _super);
1023
+ function FilterFeaturesInAreaExecutor(area, features) {
1024
+ var _this = _super.call(this) || this;
1025
+ _this.area = area;
1026
+ _this.features = features;
1027
+ return _this;
1028
+ }
1029
+ Object.defineProperty(FilterFeaturesInAreaExecutor.prototype, "id", {
1030
+ get: function () {
1031
+ return FilterFeaturesInAreaExecutor.ID;
1032
+ },
1033
+ enumerable: false,
1034
+ configurable: true
1035
+ });
1036
+ return FilterFeaturesInAreaExecutor;
1037
+ }(postboy.PostboyExecutor));
1038
+ FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
1039
+
1021
1040
  var AddLayerCommand = /** @class */ (function (_super) {
1022
1041
  __extends(AddLayerCommand, _super);
1023
1042
  function AddLayerCommand(layer) {
@@ -1211,25 +1230,6 @@
1211
1230
  return FeatureService;
1212
1231
  }());
1213
1232
 
1214
- var FilterFeaturesInAreaExecutor = /** @class */ (function (_super) {
1215
- __extends(FilterFeaturesInAreaExecutor, _super);
1216
- function FilterFeaturesInAreaExecutor(area, features) {
1217
- var _this = _super.call(this) || this;
1218
- _this.area = area;
1219
- _this.features = features;
1220
- return _this;
1221
- }
1222
- Object.defineProperty(FilterFeaturesInAreaExecutor.prototype, "id", {
1223
- get: function () {
1224
- return FilterFeaturesInAreaExecutor.ID;
1225
- },
1226
- enumerable: false,
1227
- configurable: true
1228
- });
1229
- return FilterFeaturesInAreaExecutor;
1230
- }(postboy.PostboyExecutor));
1231
- FilterFeaturesInAreaExecutor.ID = '36bb2d94-8028-4512-90dd-2386af3fc67c';
1232
-
1233
1233
  var GenerateDrawExecutor = /** @class */ (function (_super) {
1234
1234
  __extends(GenerateDrawExecutor, _super);
1235
1235
  function GenerateDrawExecutor(layer, style, type) {
@@ -1855,6 +1855,13 @@
1855
1855
  * @default 'EPSG:3857'
1856
1856
  */
1857
1857
  this.projection = 'EPSG:3857';
1858
+ /**
1859
+ * Additional headers that should be added to each tile request
1860
+ *
1861
+ * @type {Record<string, string>}
1862
+ * @default An empty array
1863
+ */
1864
+ this.requestHeaders = null;
1858
1865
  }
1859
1866
  /**
1860
1867
  * Creates a copy of the given tile layer settings.
@@ -1869,6 +1876,7 @@
1869
1876
  result.projection = model.projection;
1870
1877
  result.opacity = model.opacity;
1871
1878
  result.url = model.url;
1879
+ result.requestHeaders = model.requestHeaders;
1872
1880
  return result;
1873
1881
  };
1874
1882
  /**
@@ -1880,6 +1888,15 @@
1880
1888
  TileLayerSettings.prototype.setUrl = function (url) {
1881
1889
  return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { url: url }));
1882
1890
  };
1891
+ /**
1892
+ * Sets the requestHeaders of the TileLayerSettings object.
1893
+ *
1894
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
1895
+ * @return {TileLayerSettings} - The updated TileLayerSettings object.
1896
+ */
1897
+ TileLayerSettings.prototype.setRequestHeaders = function (requestHeaders) {
1898
+ return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { requestHeaders: requestHeaders }));
1899
+ };
1883
1900
  /**
1884
1901
  * Sets the maximum zoom level for the tile layer.
1885
1902
  *
@@ -1933,6 +1950,8 @@
1933
1950
  return false;
1934
1951
  if (this.opacity !== model.opacity)
1935
1952
  return false;
1953
+ if (this.requestHeaders !== model.requestHeaders)
1954
+ return false;
1936
1955
  return true;
1937
1956
  };
1938
1957
  return TileLayerSettings;
@@ -1942,6 +1961,7 @@
1942
1961
  function TileLayerFactory() {
1943
1962
  }
1944
1963
  TileLayerFactory.prototype.build = function (settings) {
1964
+ var _this = this;
1945
1965
  var source$1 = new source.XYZ({
1946
1966
  tileSize: 256,
1947
1967
  maxZoom: settings.maxZoom || 14,
@@ -1949,6 +1969,9 @@
1949
1969
  projection: proj.get(settings.projection),
1950
1970
  tileUrlFunction: this.getTileFunc(settings),
1951
1971
  crossOrigin: 'Anonymous',
1972
+ tileLoadFunction: !!settings.requestHeaders
1973
+ ? function (tile, src) { return _this.tileLoader(tile, src, settings.requestHeaders); }
1974
+ : undefined,
1952
1975
  });
1953
1976
  return new TileLayer__default["default"]({ source: source$1, opacity: settings.opacity });
1954
1977
  };
@@ -1966,6 +1989,21 @@
1966
1989
  .replace('{y}', String(bound - ((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.y) || y) - 1));
1967
1990
  };
1968
1991
  };
1992
+ TileLayerFactory.prototype.tileLoader = function (tile, src, headers) {
1993
+ var client = new XMLHttpRequest();
1994
+ client.open('GET', src);
1995
+ client.responseType = 'arraybuffer';
1996
+ Object.keys(headers).forEach(function (k) { return client.setRequestHeader(k, headers[k]); });
1997
+ client.onload = function () {
1998
+ if (this.response !== undefined) {
1999
+ var arrayBufferView = new Uint8Array(this.response);
2000
+ var blob = new Blob([arrayBufferView], { type: 'image/png' });
2001
+ var urlCreator = window.URL || window.webkitURL;
2002
+ tile.getImage().src = urlCreator.createObjectURL(blob);
2003
+ }
2004
+ };
2005
+ client.send();
2006
+ };
1969
2007
  TileLayerFactory.prototype.getNormalizedCoord = function (coord, zoom) {
1970
2008
  var y = coord.y;
1971
2009
  var x = coord.x;
@@ -3397,6 +3435,7 @@
3397
3435
  exports.DrawSelectionAreaCommand = DrawSelectionAreaCommand;
3398
3436
  exports.FeatureLayerComponent = FeatureLayerComponent;
3399
3437
  exports.FeatureLayerSettings = FeatureLayerSettings;
3438
+ exports.FilterFeaturesInAreaExecutor = FilterFeaturesInAreaExecutor;
3400
3439
  exports.FitToPolygonsCommand = FitToPolygonsCommand;
3401
3440
  exports.GetFeaturesInAreaQuery = GetFeaturesInAreaQuery;
3402
3441
  exports.GetMapPositionExecutor = GetMapPositionExecutor;