@@ -1754,32 +1754,39 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
17541754 animateCamera ( options : AnimateCameraOptions , nativeMap ?) : Promise < void > {
17551755 return new Promise ( ( resolve , reject ) => {
17561756 try {
1757- const target = options . target ;
1758- if ( target === undefined ) {
1759- reject ( "Please set the 'target' parameter" ) ;
1760- return ;
1761- }
1757+ const durationMs = options . duration ? options . duration : 10000 ;
1758+ if ( options . bounds ) {
1759+ const padding = options . padding || 0 ;
1760+ const bounds = new com . mapbox . mapboxsdk . geometry . LatLngBounds . Builder ( )
1761+ . include ( new com . mapbox . mapboxsdk . geometry . LatLng ( options . bounds . north , options . bounds . east ) )
1762+ . include ( new com . mapbox . mapboxsdk . geometry . LatLng ( options . bounds . south , options . bounds . west ) )
1763+ . build ( ) ;
1764+ this . _mapboxMapInstance . animateCamera ( com . mapbox . mapboxsdk . camera . CameraUpdateFactory . newLatLngBounds ( bounds , padding ) , durationMs , null ) ;
1765+ } else {
1766+ const target = options . target ;
1767+ if ( target === undefined ) {
1768+ reject ( "Please set the 'target' parameter" ) ;
1769+ return ;
1770+ }
17621771
1763- const cameraPositionBuilder = new com . mapbox . mapboxsdk . camera . CameraPosition . Builder ( this . _mapboxMapInstance . getCameraPosition ( ) ) . target (
1764- new com . mapbox . mapboxsdk . geometry . LatLng ( target . lat , target . lng )
1765- ) ;
1772+ const cameraPositionBuilder = new com . mapbox . mapboxsdk . camera . CameraPosition . Builder ( this . _mapboxMapInstance . getCameraPosition ( ) ) . target (
1773+ new com . mapbox . mapboxsdk . geometry . LatLng ( target . lat , target . lng )
1774+ ) ;
17661775
1767- if ( options . bearing ) {
1768- cameraPositionBuilder . bearing ( options . bearing ) ;
1769- }
1776+ if ( options . bearing ) {
1777+ cameraPositionBuilder . bearing ( options . bearing ) ;
1778+ }
17701779
1771- if ( options . tilt ) {
1772- cameraPositionBuilder . tilt ( options . tilt ) ;
1773- }
1780+ if ( options . tilt ) {
1781+ cameraPositionBuilder . tilt ( options . tilt ) ;
1782+ }
17741783
1775- if ( options . zoomLevel ) {
1776- cameraPositionBuilder . zoom ( options . zoomLevel ) ;
1784+ if ( options . zoomLevel ) {
1785+ cameraPositionBuilder . zoom ( options . zoomLevel ) ;
1786+ }
1787+ this . _mapboxMapInstance . animateCamera ( com . mapbox . mapboxsdk . camera . CameraUpdateFactory . newCameraPosition ( cameraPositionBuilder . build ( ) ) , durationMs , null ) ;
17771788 }
17781789
1779- const durationMs = options . duration ? options . duration : 10000 ;
1780-
1781- this . _mapboxMapInstance . animateCamera ( com . mapbox . mapboxsdk . camera . CameraUpdateFactory . newCameraPosition ( cameraPositionBuilder . build ( ) ) , durationMs , null ) ;
1782-
17831790 setTimeout ( ( ) => {
17841791 resolve ( ) ;
17851792 } , durationMs ) ;
0 commit comments