azure-maps-control 2.1.16 → 2.2.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "azure-maps-control",
3
3
  "author": "Microsoft Corporation",
4
- "version": "2.1.16",
4
+ "version": "2.2.0",
5
5
  "description": "Map SDK for Azure Maps",
6
6
  "keywords": [
7
7
  "azure",
@@ -24,7 +24,7 @@
24
24
  "posttest-filter": "npm run updatePackageVersionForTests -- --isPreTest false",
25
25
  "test-filter": "set \"TS_NODE_PROJECT=./test/tsconfig.json\" && mocha --parallel --exit --timeout 30000 --require ts-node/register",
26
26
  "thirdPartyNotices": "node ./bin/thirdPartyNotices.js",
27
- "tslint": "node_modules/.bin/tslint --project ./tsconfig.json",
27
+ "lint": "eslint -c .eslintrc.json --ext .ts,.js src/",
28
28
  "updateEnvVariables": "node ./bin/updateEnvVariables.js",
29
29
  "updateExampleKeys": "node ./bin/updateExampleKeys.js",
30
30
  "updateTestSecrets": "node ./bin/updateTestSecrets.js",
@@ -42,11 +42,15 @@
42
42
  "@types/mapbox-gl": "^1.13.0",
43
43
  "@types/mocha": "^5.2.7",
44
44
  "@types/puppeteer": "^1.20.7",
45
+ "@typescript-eslint/eslint-plugin": "^5.33.0",
46
+ "@typescript-eslint/parser": "^5.33.0",
45
47
  "adal-angular": "^1.0.18",
46
48
  "atob": "^2.1.2",
47
49
  "azuremaps-maplibre-gl": "^1.14.0-rc4",
48
50
  "cypress-multi-reporters": "^1.5.0",
49
51
  "es-abstract": "^1.17.1",
52
+ "eslint": "^8.22.0",
53
+ "eslint-plugin-security": "^1.5.0",
50
54
  "estree-walker": "^1.0.1",
51
55
  "fs-extra": "^8.1.0",
52
56
  "glob": "^7.1.6",
@@ -68,8 +72,6 @@
68
72
  "rollup-plugin-uglify": "^6.0.4",
69
73
  "simplify-ts": "^1.0.2",
70
74
  "ts-node": "^8.10.2",
71
- "tslint": "^5.20.1",
72
- "tslint-microsoft-contrib": "^6.2.0",
73
75
  "typescript": "^3.7.2",
74
76
  "utf-8-validate": "^5.0.2",
75
77
  "uuid-random": "^1.3.2",
Binary file
@@ -516,6 +516,78 @@ declare namespace atlas {
516
516
  constructor(geometries: Geometry[]);
517
517
  }
518
518
 
519
+ /**
520
+ * A `MercatorPoint` object represents a projected three dimensional position.
521
+ *
522
+ * `MercatorPoint` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units:
523
+ * - the size of 1 unit is the width of the projected world instead of the "mercator meter"
524
+ * - the origin of the coordinate space is at the north-west corner instead of the middle.
525
+ *
526
+ * For example, `MercatorPoint(0, 0, 0)` is the north-west corner of the mercator world and
527
+ * `MercatorPoint(1, 1, 0)` is the south-east corner. If you are familiar with
528
+ * [vector tiles](https://github.com/mapbox/vector-tile-spec) it may be helpful to think
529
+ * of the coordinate space as the `0/0/0` tile with an extent of `1`.
530
+ *
531
+ * The `z` dimension of `MercatorPoint` is conformal. A cube in the mercator coordinate space would be rendered as a cube.
532
+ */
533
+ export class MercatorPoint extends Array<number> {
534
+ /**
535
+ * Constructs a MercatorPoint.
536
+ * @param x A points x position in mercator units.
537
+ * @param y A points y position in mercator units.
538
+ * @param z A points z position in mercator units.
539
+ */
540
+ constructor(x: number, y: number, z?: number);
541
+ /**
542
+ * Converts a position into a mercator point.
543
+ * @param position Position to convert.
544
+ * @returns A mercator point.
545
+ */
546
+ static fromPosition(position: Position): MercatorPoint;
547
+ /**
548
+ * Converts an array of positions into an array of mercator points.
549
+ * @param positions Array of positions to convert.
550
+ * @returns An array of mercator points.
551
+ */
552
+ static fromPositions(positions: Position[]): MercatorPoint[];
553
+ /**
554
+ * Converts an array of positions into a Float32Array of mercator xyz values.
555
+ * @param positions Array of positions to convert.
556
+ * @returns A Float32Array of mercator xyz values.
557
+ */
558
+ static toFloat32Array(positions: Position[]): Float32Array;
559
+ /**
560
+ * Converts a mercator point into a map position.
561
+ * @param mercator Mercator point to convert.
562
+ * @returns A map position.
563
+ */
564
+ static toPosition(mercator: MercatorPoint): Position;
565
+ /**
566
+ * Converts an array of mercator points into an array of map positions.
567
+ * @param mercators Mercator points to convert.
568
+ * @returns An array of map positions.
569
+ */
570
+ static toPositions(mercators: MercatorPoint[]): Position[];
571
+ /**
572
+ * Determine the Mercator scale factor for a given latitude, see
573
+ * https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor
574
+ *
575
+ * At the equator the scale factor will be 1, which increases at higher latitudes.
576
+ *
577
+ * @param latitude Latitude
578
+ * @returns The mercator scale factor.
579
+ */
580
+ static mercatorScale(latitude: number): number;
581
+ /**
582
+ * Returns the distance of 1 meter in `MercatorPoint` units at this latitude.
583
+ *
584
+ * For coordinates in real world units using meters, this naturally provides the scale
585
+ * to transform into `MercatorPoint`s.
586
+ *
587
+ * @returns {number} Distance of 1 meter in `MercatorPoint` units.
588
+ */
589
+ static meterInMercatorUnits(latitude: number): number;
590
+ }
519
591
  }
520
592
 
521
593
  //control classes
@@ -817,7 +889,6 @@ declare namespace atlas {
817
889
  * @param newOptions The new options of the bubble layer.
818
890
  */
819
891
  setOptions(options: BubbleLayerOptions): void;
820
-
821
892
  }
822
893
 
823
894
  export interface LayerEvents {
@@ -1072,6 +1143,27 @@ declare namespace atlas {
1072
1143
  */
1073
1144
  setOptions(options: TileLayerOptions): void;
1074
1145
  }
1146
+
1147
+ /**
1148
+ * Enables custom rendering logic with access to the WebGL context of the map.
1149
+ */
1150
+ export class WebGLLayer extends Layer {
1151
+ /**
1152
+ * Constructs a new WebGLLayer.
1153
+ * @param id The id of the layer. If not specified a random one will be generated.
1154
+ * @param options The options of the WebGL layer.
1155
+ */
1156
+ constructor(id?: string, options?: WebGLLayerOptions);
1157
+ /**
1158
+ * Gets the options of the WebGL layer.
1159
+ */
1160
+ getOptions(): WebGLLayerOptions;
1161
+ /**
1162
+ * Sets the options of the WebGL layer.
1163
+ * @param options The new options of the WebGL layer.
1164
+ */
1165
+ setOptions(options: WebGLLayerOptions): void;
1166
+ }
1075
1167
  }
1076
1168
 
1077
1169
  //source classes
@@ -1907,8 +1999,9 @@ declare namespace atlas {
1907
1999
  /**
1908
2000
  * Set the map control's style options. Any options not specified will default to their current values.
1909
2001
  * @param options The options for setting the style of the map control.
2002
+ * @param diff [true] If false, forces a 'full' style update, removing the current style and building the given one instead of attempting a diff-based update. Defaults to true.
1910
2003
  */
1911
- setStyle(options?: StyleOptions): void;
2004
+ setStyle(options?: StyleOptions, diff?: boolean): void;
1912
2005
  /**
1913
2006
  * Returns the map control's current style settings.
1914
2007
  */
@@ -1970,6 +2063,14 @@ declare namespace atlas {
1970
2063
  * Stops any animated transition that is currently underway.
1971
2064
  */
1972
2065
  stop(): void;
2066
+ /**
2067
+ * Trigger the rendering of a single frame.
2068
+ * Use this method with WebGL layers to repaint the map when the layer's
2069
+ * properties or properties associated with the layer's source change.
2070
+ * Calling this multiple times before the next frame is rendered will still
2071
+ * result in only a single frame being rendered.
2072
+ */
2073
+ triggerRepaint(): void;
1973
2074
  /**
1974
2075
  * The callback used when styleOptions.autoResize is true.
1975
2076
  */
@@ -2093,6 +2194,10 @@ declare namespace atlas {
2093
2194
  * Returns the options for the popup.
2094
2195
  */
2095
2196
  getOptions(): PopupOptions;
2197
+ /**
2198
+ * Returns popup container element.
2199
+ */
2200
+ getPopupContainer(): HTMLElement
2096
2201
  /**
2097
2202
  * Attaches the popup to the HTML document in a hidden state.
2098
2203
  * @param map The map.
@@ -3519,6 +3624,16 @@ declare namespace atlas {
3519
3624
  tileUrl?: string;
3520
3625
  }
3521
3626
 
3627
+ /**
3628
+ * Options used to render graphics in a WebGLLayer.
3629
+ */
3630
+ export interface WebGLLayerOptions extends LayerOptions {
3631
+ /**
3632
+ * An object that contains the rendering logic.
3633
+ */
3634
+ renderer?: WebGLRenderer;
3635
+ }
3636
+
3522
3637
  /**
3523
3638
  * Available styles for a Control.
3524
3639
  */
@@ -4126,6 +4241,10 @@ declare namespace atlas {
4126
4241
  * The options for the map's style.
4127
4242
  */
4128
4243
  export interface StyleOptions extends Options {
4244
+ /**
4245
+ * If true, the gl context will be created with MSAA antialiasing, which can be useful for antialiasing WebGL layers.
4246
+ */
4247
+ antialias?: boolean;
4129
4248
  /**
4130
4249
  * If true the map will automatically resize whenever the window's size changes.
4131
4250
  * Otherwise map.resize() must be called.
@@ -4177,6 +4296,11 @@ declare namespace atlas {
4177
4296
  * @default true
4178
4297
  */
4179
4298
  showLogo?: boolean;
4299
+ /**
4300
+ * Specifies if the map should display labels
4301
+ * @default true
4302
+ */
4303
+ showLabels?: boolean;
4180
4304
  /**
4181
4305
  * Specifies if the map should render an outline around each tile and the tile ID.
4182
4306
  * These tile boundaries are useful for debugging.
@@ -4357,7 +4481,12 @@ declare namespace atlas {
4357
4481
  * Allows a callback responsible for acquiring an authentication token to be provided.
4358
4482
  * Literal value `"anonymous"`
4359
4483
  */
4360
- anonymous = "anonymous"
4484
+ anonymous = "anonymous",
4485
+ /**
4486
+ * The shared access signature authentication mechanism. Allows a callback responsible for acquiring a token to be provided on requests.
4487
+ * Literal value `"sas"`.
4488
+ */
4489
+ sas = "sas"
4361
4490
  }
4362
4491
 
4363
4492
  /**
@@ -4395,11 +4524,15 @@ declare namespace atlas {
4395
4524
  */
4396
4525
  aadInstance?: string;
4397
4526
  /**
4398
- * A callback to use with the anonymous authentication mechanism.
4527
+ * A callback to use with the anonymous/sas authentication mechanism.
4399
4528
  * This callback will be responsible for resolving to a authentication token.
4400
4529
  * E.g. fetching a CORS protected token from an endpoint.
4401
4530
  */
4402
4531
  getToken?: getAuthTokenCallback;
4532
+ /**
4533
+ * Optionally provide an initial token for sas authentication.
4534
+ */
4535
+ sasToken?: string;
4403
4536
  /**
4404
4537
  * Optionally provide an existing `AuthenticationContext` from the ADAL.js library.
4405
4538
  * This authentication context will be used to acquire the AAD token.
@@ -4427,6 +4560,11 @@ declare namespace atlas {
4427
4560
  * @param getTokenCallback Callback function responsible for resolving to an authentication token.
4428
4561
  */
4429
4562
  setTokenCallbackFunction?(getTokenCallback: getAuthTokenCallback): void;
4563
+ /**
4564
+ * Sets the required options to configure the sas authentication method.
4565
+ * @param getTokenCallback Callback function responsible for resolving to an authentication token.
4566
+ */
4567
+ setSasCallbackFunction?(getTokenCallback: getAuthTokenCallback): void;
4430
4568
  }
4431
4569
 
4432
4570
  export type ResourceType =
@@ -4443,21 +4581,21 @@ declare namespace atlas {
4443
4581
  | 'Thumbnail';
4444
4582
 
4445
4583
  /**
4446
- * Represents the contents of the style set.
4584
+ * Represents the contents of map configuration holding a list of styles available to them.
4447
4585
  */
4448
- export interface StyleSet {
4586
+ export interface MapConfiguration {
4449
4587
  created?: string;
4450
- defaultStyle: string;
4588
+ defaultConfiguration: string;
4451
4589
  description?: string;
4452
4590
  id?: string;
4453
- styles: StyleSetStyle[];
4591
+ configurations: MapConfigurationStyle[];
4454
4592
  version?: number;
4455
4593
  }
4456
4594
 
4457
4595
  /**
4458
4596
  * Represents the info for a single style.
4459
4597
  */
4460
- export interface StyleSetStyle {
4598
+ export interface MapConfigurationStyle {
4461
4599
  copyright?: string;
4462
4600
  displayName?: string;
4463
4601
  name: string;
@@ -4493,10 +4631,9 @@ declare namespace atlas {
4493
4631
  */
4494
4632
  domain?: string;
4495
4633
  /**
4496
- * The style set of the map. Determines which styles are available to be picked
4497
- * and what do they consist of (style names, thumbnails, URLs, etc).
4634
+ * The map configuration defines the set of styles available to the map.
4498
4635
  */
4499
- styleSet?: StyleSet;
4636
+ mapConfiguration?: string | MapConfiguration;
4500
4637
  /**
4501
4638
  * Enable accessibility
4502
4639
  * default: true
@@ -4584,6 +4721,75 @@ declare namespace atlas {
4584
4721
  export interface AggregateExpression extends Array<any> {
4585
4722
  }
4586
4723
 
4724
+ /**
4725
+ * Interface for rendering WebGL graphics in a WebGLLayer.
4726
+ */
4727
+ export interface WebGLRenderer {
4728
+ /**
4729
+ * Either "2d" or "3d". Defaults to "2d".
4730
+ */
4731
+ renderingMode?: "2d" | "3d";
4732
+
4733
+ /**
4734
+ * Optional method called when the layer has been added to the Map.
4735
+ * This gives the layer a chance to initialize gl resources and register event listeners.
4736
+ * @param map The Map this WebGL layer was just added to.
4737
+ * @param gl The gl context for the map.
4738
+ */
4739
+ onAdd?(map: Map, gl: WebGLRenderingContext): void;
4740
+
4741
+ /**
4742
+ * Optional method called when the layer has been removed from the Map.
4743
+ * This gives the layer a chance to clean up gl resources and event listeners.
4744
+ * @param map The Map this WebGL layer was just added to.
4745
+ * @param gl The gl context for the map.
4746
+ */
4747
+ onRemove?(map: Map, gl: WebGLRenderingContext): void;
4748
+
4749
+ /**
4750
+ * Optional method called during a render frame to allow a layer to prepare resources
4751
+ * or render into a texture.
4752
+ *
4753
+ * The layer cannot make any assumptions about the current GL state and must bind a framebuffer
4754
+ * before rendering.
4755
+ * @param gl The map's gl context.
4756
+ * @param matrix The map's camera matrix. It projects spherical mercator coordinates to gl
4757
+ * coordinates. The mercator coordinate [0, 0] represents the top left corner of
4758
+ * the mercator world and [1, 1] represents the bottom right corner. When the
4759
+ * renderingMode is "3d" , the z coordinate is conformal. A box with identical
4760
+ * x, y, and z lengths in mercator units would be rendered as a cube.
4761
+ * MercatorCoordinate .fromLatLng can be used to project a LngLat to a mercator
4762
+ * coordinate.
4763
+ */
4764
+ prerender?(gl: WebGLRenderingContext, matrix: number[]): void;
4765
+
4766
+ /**
4767
+ * Called during a render frame allowing the layer to draw into the GL context.
4768
+ *
4769
+ * The layer can assume blending and depth state is set to allow the layer to properly blend
4770
+ * and clip other layers. The layer cannot make any other assumptions about the current GL state.
4771
+ *
4772
+ * If the layer needs to render to a texture, it should implement the prerender method to do this
4773
+ * and only use the render method for drawing directly into the main framebuffer.
4774
+ *
4775
+ * The blend function is set to gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA). This expects
4776
+ * colors to be provided in premultiplied alpha form where the r, g and b values are already
4777
+ * multiplied by the a value. If you are unable to provide colors in premultiplied form you may
4778
+ * want to change the blend function to
4779
+ * gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA).
4780
+ *
4781
+ * @param gl The map's gl context.
4782
+ * @param matrix The map's camera matrix. It projects spherical mercator coordinates to gl
4783
+ * coordinates. The mercator coordinate [0, 0] represents the top left corner of
4784
+ * the mercator world and [1, 1] represents the bottom right corner. When the
4785
+ * renderingMode is "3d" , the z coordinate is conformal. A box with identical
4786
+ * x, y, and z lengths in mercator units would be rendered as a cube.
4787
+ * MercatorCoordinate .fromLatLng can be used to project a LngLat to a mercator
4788
+ * coordinate.
4789
+ */
4790
+ render(gl: WebGLRenderingContext, matrix: number[]): void;
4791
+ }
4792
+
4587
4793
  /**
4588
4794
  * A manager for the map control's authentication.
4589
4795
  * Exposed through the authentication property of the atlas.Map class.
@@ -4683,11 +4889,11 @@ declare namespace atlas {
4683
4889
  */
4684
4890
  add(eventType: "stylechanged", callback: (e: StyleChangedEvent) => void): void;
4685
4891
  /**
4686
- * Adds a styleset change event to the map.
4687
- * @param eventType A styleset changed event name
4892
+ * Adds a mapConfiguration change event to the map.
4893
+ * @param eventType A mapConfiguration changed event name
4688
4894
  * @param callback The event handler callback
4689
4895
  */
4690
- add(eventType: "stylesetchanged", callback: (e: StyleSet) => void): void;
4896
+ add(eventType: "mapconfigurationchanged", callback: (e: MapConfiguration) => void): void;
4691
4897
  /**
4692
4898
  * Adds a wheel event to the map.
4693
4899
  * @param eventType The wheel event name.
@@ -4964,7 +5170,7 @@ declare namespace atlas {
4964
5170
  * @param eventType The event name.
4965
5171
  * @param callback The event handler callback.
4966
5172
  */
4967
- remove(eventType: string, callback: (e: void | atlas.layer.Layer | MapEvent | MapDataEvent | MapMouseEvent | MapTouchEvent | MapMouseWheelEvent | atlas.source.Source | string | StyleSet) => void): void;
5173
+ remove(eventType: string, callback: (e: void | atlas.layer.Layer | MapEvent | MapDataEvent | MapMouseEvent | MapTouchEvent | MapMouseWheelEvent | atlas.source.Source | string | MapConfiguration) => void): void;
4968
5174
  /**
4969
5175
  * Removes an event listener from the DataSource(s).
4970
5176
  * @param eventType The event name.