From ff15905467060f1b890d526b6176ad665a487955 Mon Sep 17 00:00:00 2001 From: Karim Naaji Date: Thu, 15 Jul 2021 10:30:45 -0700 Subject: [PATCH] Last public facing examples --- src/ui/camera.js | 8 ++++++++ src/ui/events.js | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/ui/camera.js b/src/ui/camera.js index 8fcc03b5aa7..a4244b010c9 100644 --- a/src/ui/camera.js +++ b/src/ui/camera.js @@ -345,6 +345,8 @@ class Camera extends Evented { * @memberof Map# * @returns The map's current bearing. * @see [Navigate the map with game-like controls](https://www.mapbox.com/mapbox-gl-js/example/game-controls/) + * @example + * const bearing = map.getBearing(); */ getBearing(): number { return this.transform.bearing; } @@ -374,6 +376,8 @@ class Camera extends Evented { * * @memberof Map# * @returns The current padding around the map viewport. + * @example + * const padding = map.getPadding(); */ getPadding(): PaddingOptions { return this.transform.padding; } @@ -486,6 +490,8 @@ class Camera extends Evented { * * @memberof Map# * @returns The map's current pitch, measured in degrees away from the plane of the screen. + * @example + * const pitch = map.getPitch(); */ getPitch(): number { return this.transform.pitch; } @@ -1481,6 +1487,8 @@ class Camera extends Evented { * * @memberof Map# * @returns {Map} `this` + * @example + * map.stop(); */ stop(): this { return this._stop(); diff --git a/src/ui/events.js b/src/ui/events.js index c7b4badaa5b..1d177fdccb0 100644 --- a/src/ui/events.js +++ b/src/ui/events.js @@ -105,6 +105,10 @@ export class MapMouseEvent extends Event { * * On `mousedown` events, the behavior of {@link BoxZoomHandler} * * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler} * + * @example + * map.on('click', (e) => { + * e.preventDefault(); + * }); */ preventDefault() { this._defaultPrevented = true; @@ -244,6 +248,10 @@ export class MapTouchEvent extends Event { * * On `touchstart` events, the behavior of {@link DragPanHandler} * * On `touchstart` events, the behavior of {@link TouchZoomRotateHandler} * + * @example + * map.on('touchstart', (e) => { + * e.preventDefault(); + * }); */ preventDefault() { this._defaultPrevented = true; @@ -308,6 +316,11 @@ export class MapWheelEvent extends Event { * Prevents subsequent default processing of the event by the map. * * Calling this method will prevent the the behavior of {@link ScrollZoomHandler}. + * @example + * map.on('wheel', (e) => { + * // Prevent the default map scroll zoom behavior. + * e.preventDefault(); + * }); */ preventDefault() { this._defaultPrevented = true;