azure-maps-control 2.1.17 → 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.17",
4
+ "version": "2.2.0",
5
5
  "description": "Map SDK for Azure Maps",
6
6
  "keywords": [
7
7
  "azure",
@@ -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
@@ -1971,6 +2063,14 @@ declare namespace atlas {
1971
2063
  * Stops any animated transition that is currently underway.
1972
2064
  */
1973
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;
1974
2074
  /**
1975
2075
  * The callback used when styleOptions.autoResize is true.
1976
2076
  */
@@ -3524,6 +3624,16 @@ declare namespace atlas {
3524
3624
  tileUrl?: string;
3525
3625
  }
3526
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
+
3527
3637
  /**
3528
3638
  * Available styles for a Control.
3529
3639
  */
@@ -4131,6 +4241,10 @@ declare namespace atlas {
4131
4241
  * The options for the map's style.
4132
4242
  */
4133
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;
4134
4248
  /**
4135
4249
  * If true the map will automatically resize whenever the window's size changes.
4136
4250
  * Otherwise map.resize() must be called.
@@ -4467,21 +4581,21 @@ declare namespace atlas {
4467
4581
  | 'Thumbnail';
4468
4582
 
4469
4583
  /**
4470
- * Represents the contents of the style set.
4584
+ * Represents the contents of map configuration holding a list of styles available to them.
4471
4585
  */
4472
- export interface StyleSet {
4586
+ export interface MapConfiguration {
4473
4587
  created?: string;
4474
- defaultStyle: string;
4588
+ defaultConfiguration: string;
4475
4589
  description?: string;
4476
4590
  id?: string;
4477
- styles: StyleSetStyle[];
4591
+ configurations: MapConfigurationStyle[];
4478
4592
  version?: number;
4479
4593
  }
4480
4594
 
4481
4595
  /**
4482
4596
  * Represents the info for a single style.
4483
4597
  */
4484
- export interface StyleSetStyle {
4598
+ export interface MapConfigurationStyle {
4485
4599
  copyright?: string;
4486
4600
  displayName?: string;
4487
4601
  name: string;
@@ -4517,10 +4631,9 @@ declare namespace atlas {
4517
4631
  */
4518
4632
  domain?: string;
4519
4633
  /**
4520
- * The style set of the map. Determines which styles are available to be picked
4521
- * and what do they consist of (style names, thumbnails, URLs, etc).
4634
+ * The map configuration defines the set of styles available to the map.
4522
4635
  */
4523
- styleSet?: StyleSet;
4636
+ mapConfiguration?: string | MapConfiguration;
4524
4637
  /**
4525
4638
  * Enable accessibility
4526
4639
  * default: true
@@ -4608,6 +4721,75 @@ declare namespace atlas {
4608
4721
  export interface AggregateExpression extends Array<any> {
4609
4722
  }
4610
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
+
4611
4793
  /**
4612
4794
  * A manager for the map control's authentication.
4613
4795
  * Exposed through the authentication property of the atlas.Map class.
@@ -4707,11 +4889,11 @@ declare namespace atlas {
4707
4889
  */
4708
4890
  add(eventType: "stylechanged", callback: (e: StyleChangedEvent) => void): void;
4709
4891
  /**
4710
- * Adds a styleset change event to the map.
4711
- * @param eventType A styleset changed event name
4892
+ * Adds a mapConfiguration change event to the map.
4893
+ * @param eventType A mapConfiguration changed event name
4712
4894
  * @param callback The event handler callback
4713
4895
  */
4714
- add(eventType: "stylesetchanged", callback: (e: StyleSet) => void): void;
4896
+ add(eventType: "mapconfigurationchanged", callback: (e: MapConfiguration) => void): void;
4715
4897
  /**
4716
4898
  * Adds a wheel event to the map.
4717
4899
  * @param eventType The wheel event name.
@@ -4988,7 +5170,7 @@ declare namespace atlas {
4988
5170
  * @param eventType The event name.
4989
5171
  * @param callback The event handler callback.
4990
5172
  */
4991
- 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;
4992
5174
  /**
4993
5175
  * Removes an event listener from the DataSource(s).
4994
5176
  * @param eventType The event name.