-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add support for 'duration' and 'bounds' * return promise for camera animation
- Loading branch information
Hsieh Chin Fan
committed
Nov 3, 2024
1 parent
b35dc99
commit 962bdeb
Showing
3 changed files
with
57 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import { | |
renderByScriptTargetWith, | ||
} from './mapclay.mjs' | ||
/* eslint-disable-next-line no-unused-vars */ | ||
import * as M from 'maplibre-gl' | ||
import maplibregl from 'maplibre-gl' | ||
import { addProtocols } from 'maplibre-gl-vector-text-protocol' | ||
import { TerraDrawMapLibreGLAdapter } from 'terra-draw' | ||
loadCSS('https://unpkg.com/[email protected]/dist/maplibre-gl.css') | ||
|
@@ -190,16 +190,25 @@ const Renderer = class extends defaultExport { | |
} | ||
} | ||
|
||
updateCamera (options, useAnimation) { | ||
if (useAnimation) { | ||
async updateCamera ({ bounds, center, zoom, animation, ...others }, useAnimation) { | ||
if (bounds) { | ||
this.map.fitBounds(bounds, { linear: true, ...others }) | ||
} else if (animation || useAnimation) { | ||
this.map.flyTo({ | ||
center: options.center, | ||
zoom: options.zoom, | ||
center: center ?? this.map.getCenter(), | ||
zoom: zoom ?? this.map.getZoom(), | ||
...others, | ||
}) | ||
} else { | ||
this.map.setCenter(options.center) | ||
this.map.setZoom(options.zoom) | ||
this.map.setCenter(center) | ||
this.map.setZoom(zoom) | ||
} | ||
|
||
return new Promise(resolve => { | ||
this.map.on('zoomend', () => { | ||
resolve('zoomend') | ||
}) | ||
}) | ||
} | ||
|
||
project ([lng, lat]) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters