Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docsprint] Add inline examples for map zoom-related methods #9594

Merged
merged 1 commit into from
Apr 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/ui/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ class Camera extends Evented {
*
* @memberof Map#
* @returns The map's current zoom level.
* @example
* map.getZoom();
*/
getZoom(): number { return this.transform.zoom; }

Expand All @@ -194,7 +196,7 @@ class Camera extends Evented {
* @fires zoomend
* @returns {Map} `this`
* @example
* // zoom the map to 5
* // zoom the map to 5 without an animated transition
* map.setZoom(5);
*/
setZoom(zoom: number, eventData?: Object) {
Expand All @@ -216,6 +218,14 @@ class Camera extends Evented {
* @fires moveend
* @fires zoomend
* @returns {Map} `this`
* @example
* // zoom the map to 5 with an animated transition
* map.zoomTo(5);
* // zoom the map to 8 with custom animation options
* map.zoomTo(8, {
* duration: 2000,
* offset: [100, 50]
* });
*/
zoomTo(zoom: number, options: ? AnimationOptions, eventData?: Object) {
return this.easeTo(extend({
Expand All @@ -236,6 +246,9 @@ class Camera extends Evented {
* @fires moveend
* @fires zoomend
* @returns {Map} `this`
* @example
* // zoom the map in one level with a custom animation duration
* map.zoomIn({duration: 1000});
*/
zoomIn(options?: AnimationOptions, eventData?: Object) {
this.zoomTo(this.getZoom() + 1, options, eventData);
Expand All @@ -255,6 +268,9 @@ class Camera extends Evented {
* @fires moveend
* @fires zoomend
* @returns {Map} `this`
* @example
* // zoom the map out one level with a custom animation offset
* map.zoomOut({offset: [80, 60]});
*/
zoomOut(options?: AnimationOptions, eventData?: Object) {
this.zoomTo(this.getZoom() - 1, options, eventData);
Expand Down