@@ -1803,16 +1803,26 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
1803
1803
return Promise . reject ( "'setOnFlingListener' is not supported on iOS" ) ;
1804
1804
}
1805
1805
1806
- setOnCameraMoveListener ( listener : ( ) => void , nativeMap ?: any ) : Promise < void > {
1807
- return Promise . reject ( "'setOnCameraMoveListener' not currently supported on iOS" ) ;
1806
+ async setOnCameraMoveListener ( listener : ( ) => void , nativeMap ?: any ) : Promise < void > {
1807
+ const theMap : MGLMapView = nativeMap || this . _mapboxViewInstance ;
1808
+ if ( theMap ) {
1809
+ ( theMap . delegate as MGLMapViewDelegateImpl ) . setCameraChangedListener ( listener ) ;
1810
+ } else {
1811
+ return Promise . reject ( 'No map has been loaded' ) ;
1812
+ }
1808
1813
}
1809
1814
1810
1815
setOnCameraMoveCancelListener ( listener : ( ) => void , nativeMap ?: any ) : Promise < void > {
1811
1816
return Promise . reject ( "'setOnCameraMoveCancelListener' not currently supported on iOS" ) ;
1812
1817
}
1813
1818
1814
- setOnCameraIdleListener ( listener : ( ) => void , nativeMap ?: any ) : Promise < void > {
1815
- return Promise . reject ( "'setOnCameraIdleListener' not currently supported on iOS" ) ;
1819
+ async setOnCameraIdleListener ( listener : ( ) => void , nativeMap ?: any ) : Promise < void > {
1820
+ const theMap : MGLMapView = nativeMap || this . _mapboxViewInstance ;
1821
+ if ( theMap ) {
1822
+ ( theMap . delegate as MGLMapViewDelegateImpl ) . setCameraIdledListener ( listener ) ;
1823
+ } else {
1824
+ return Promise . reject ( 'No map has been loaded' ) ;
1825
+ }
1816
1826
}
1817
1827
1818
1828
getViewport ( nativeMap ?) : Promise < Viewport > {
@@ -2517,10 +2527,11 @@ class MGLMapViewDelegateImpl extends NSObject implements MGLMapViewDelegate {
2517
2527
2518
2528
private userLocationClickListener : ( annotation : MGLAnnotation ) => void ;
2519
2529
private userLocationChangedListener : ( location : UserLocation ) => void ;
2530
+ private cameraChangedListener : ( ) => void ;
2531
+ private cameraIdledListener : ( ) => void ;
2520
2532
private userLocationRenderMode : any ;
2521
2533
private userLocationAnnotationView : CustomUserLocationAnnotationView ;
2522
2534
2523
-
2524
2535
/**
2525
2536
* initialize with the mapReady callback
2526
2537
*/
@@ -2533,7 +2544,6 @@ class MGLMapViewDelegateImpl extends NSObject implements MGLMapViewDelegate {
2533
2544
return this ;
2534
2545
}
2535
2546
2536
-
2537
2547
/**
2538
2548
* set a reference to the mapboxAPI instance
2539
2549
*/
@@ -2562,6 +2572,20 @@ class MGLMapViewDelegateImpl extends NSObject implements MGLMapViewDelegate {
2562
2572
this . userLocationAnnotationView . changeUserLocationRenderMode ( userLocationRenderMode ) ;
2563
2573
}
2564
2574
2575
+ /**
2576
+ * set the camera changd listener callback
2577
+ */
2578
+ setCameraChangedListener ( callback ) {
2579
+ this . cameraChangedListener = callback ;
2580
+ }
2581
+
2582
+ /**
2583
+ * set the camera idled listener callback
2584
+ */
2585
+ setCameraIdledListener ( callback ) {
2586
+ this . cameraIdledListener = callback ;
2587
+ }
2588
+
2565
2589
/**
2566
2590
* set style loaded callback.
2567
2591
*
@@ -2778,9 +2802,26 @@ class MGLMapViewDelegateImpl extends NSObject implements MGLMapViewDelegate {
2778
2802
return null ;
2779
2803
}
2780
2804
2805
+ mapViewRegionIsChanging ( ) {
2806
+ if ( Trace . isEnabled ( ) ) {
2807
+ CLog ( CLogTypes . info , 'MGLMapViewDelegateImpl::mapViewRegionIsChanging()' ) ;
2808
+ }
2809
+ if ( this . cameraChangedListener ) {
2810
+ this . cameraChangedListener ( ) ;
2811
+ }
2812
+ }
2813
+ mapViewRegionDidChangeAnimated ( animated ) {
2814
+ if ( Trace . isEnabled ( ) ) {
2815
+ CLog ( CLogTypes . info , 'MGLMapViewDelegateImpl::mapViewRegionDidChangeAnimated()' ) ;
2816
+ }
2817
+ if ( this . cameraIdledListener ) {
2818
+ this . cameraIdledListener ( ) ;
2819
+ }
2820
+ }
2821
+
2781
2822
mapViewDidUpdateUserLocation ( mapView : MGLMapView , userLocation : MGLUserLocation ) {
2782
2823
if ( Trace . isEnabled ( ) ) {
2783
- CLog ( CLogTypes . info , 'MGLMapViewDelegateImpl::mapViewDidUpdateUserLocation() top ' ) ;
2824
+ CLog ( CLogTypes . info , 'MGLMapViewDelegateImpl::mapViewDidUpdateUserLocation()' ) ;
2784
2825
}
2785
2826
if ( this . userLocationChangedListener ) {
2786
2827
this . userLocationChangedListener ( _getLocation ( userLocation ) ) ;
0 commit comments