@@ -1754,32 +1754,39 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
1754
1754
animateCamera ( options : AnimateCameraOptions , nativeMap ?) : Promise < void > {
1755
1755
return new Promise ( ( resolve , reject ) => {
1756
1756
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
+ }
1762
1771
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
+ ) ;
1766
1775
1767
- if ( options . bearing ) {
1768
- cameraPositionBuilder . bearing ( options . bearing ) ;
1769
- }
1776
+ if ( options . bearing ) {
1777
+ cameraPositionBuilder . bearing ( options . bearing ) ;
1778
+ }
1770
1779
1771
- if ( options . tilt ) {
1772
- cameraPositionBuilder . tilt ( options . tilt ) ;
1773
- }
1780
+ if ( options . tilt ) {
1781
+ cameraPositionBuilder . tilt ( options . tilt ) ;
1782
+ }
1774
1783
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 ) ;
1777
1788
}
1778
1789
1779
- const durationMs = options . duration ? options . duration : 10000 ;
1780
-
1781
- this . _mapboxMapInstance . animateCamera ( com . mapbox . mapboxsdk . camera . CameraUpdateFactory . newCameraPosition ( cameraPositionBuilder . build ( ) ) , durationMs , null ) ;
1782
-
1783
1790
setTimeout ( ( ) => {
1784
1791
resolve ( ) ;
1785
1792
} , durationMs ) ;
0 commit comments