@@ -369,7 +369,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
369369
370370 private circleManager : any = null ;
371371 private lineManager : any = null ;
372- private symbolManager : any = null ;
372+ private symbolManager : com . mapbox . mapboxsdk . plugins . annotation . SymbolManager = null ;
373373
374374 private _offlineManager : any ;
375375
@@ -379,6 +379,8 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
379379 private onMapReadyCallback ;
380380 private onDidFinishLoadingStyleListener ;
381381 private onAnnotationClickListener ;
382+ private onMarkerClickListener ;
383+ private onInfoWindowClickListener ;
382384 private onMapClickListener ;
383385 private onMapLongClickListener ;
384386 private onMoveListener ;
@@ -776,6 +778,14 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
776778 this . lineManager . removeClickListener ( this . onAnnotationClickListener ) ;
777779 this . onAnnotationClickListener = null ;
778780 }
781+ if ( this . onMarkerClickListener ) {
782+ this . _mapboxMapInstance . setOnMarkerClickListener ( null ) ;
783+ this . onMarkerClickListener = null ;
784+ }
785+ if ( this . onInfoWindowClickListener ) {
786+ this . _mapboxMapInstance . setOnInfoWindowClickListener ( null ) ;
787+ this . onInfoWindowClickListener = null ;
788+ }
779789
780790 if ( this . onDidFailLoadingMapListener ) {
781791 this . _mapboxViewInstance . removeOnDidFailLoadingMapListener ( this . onDidFailLoadingMapListener ) ;
@@ -1057,9 +1067,22 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
10571067 // FIXME: now that the map is initialized and the style is loaded we can
10581068 // create the annotation managers that allow us to (hopefully) reliably
10591069 // receive events on lines
1060-
1061- this . lineManager = new com . mapbox . mapboxsdk . plugins . annotation . LineManager ( this . _mapboxViewInstance , this . _mapboxMapInstance , this . _mapboxMapInstance . getStyle ( ) ) ;
1062-
1070+ const nMapbox = this . _mapboxMapInstance ;
1071+ const nMapView = this . _mapboxViewInstance ;
1072+ const nStyle = nMapbox . getStyle ( ) ;
1073+ this . lineManager = new com . mapbox . mapboxsdk . plugins . annotation . LineManager ( nMapView , nMapbox , nStyle ) ;
1074+ // this.symbolManager = new com.mapbox.mapboxsdk.plugins.annotation.SymbolManager(nMapView, nMapbox, nStyle);
1075+ // this.symbolManager.addClickListener(
1076+ // new com.mapbox.mapboxsdk.plugins.annotation.OnSymbolClickListener({
1077+ // onAnnotationClick: (marker: com.mapbox.mapboxsdk.plugins.annotation.Symbol) => {
1078+ // const cachedMarker = this._getClickedMarkerDetails(marker);
1079+ // if (cachedMarker && cachedMarker.onTap) {
1080+ // cachedMarker.onTap(cachedMarker);
1081+ // }
1082+ // return false;
1083+ // },
1084+ // })
1085+ // );
10631086 this . onAnnotationClickListener = new com . mapbox . mapboxsdk . plugins . annotation . OnAnnotationClickListener ( {
10641087 onAnnotationClick : ( line ) => {
10651088 if ( Trace . isEnabled ( ) ) {
@@ -1228,32 +1251,34 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
12281251 if ( ! this . _mapboxMapInstance ) {
12291252 return ;
12301253 }
1231-
1232- this . _mapboxMapInstance . setOnMarkerClickListener (
1233- new com . mapbox . mapboxsdk . maps . MapboxMap . OnMarkerClickListener ( {
1254+ if ( ! this . onMarkerClickListener ) {
1255+ this . onMarkerClickListener = new com . mapbox . mapboxsdk . maps . MapboxMap . OnMarkerClickListener ( {
12341256 onMarkerClick : ( marker ) => {
12351257 const cachedMarker = this . _getClickedMarkerDetails ( marker ) ;
12361258 if ( cachedMarker && cachedMarker . onTap ) {
12371259 cachedMarker . onTap ( cachedMarker ) ;
12381260 }
12391261 return false ;
12401262 } ,
1241- } )
1242- ) ;
1243-
1244- this . _mapboxMapInstance . setOnInfoWindowClickListener (
1245- new com . mapbox . mapboxsdk . maps . MapboxMap . OnInfoWindowClickListener ( {
1263+ } ) ;
1264+ this . _mapboxMapInstance . setOnMarkerClickListener ( this . onMarkerClickListener ) ;
1265+ }
1266+ if ( ! this . onInfoWindowClickListener ) {
1267+ this . onInfoWindowClickListener = new com . mapbox . mapboxsdk . maps . MapboxMap . OnInfoWindowClickListener ( {
12461268 onInfoWindowClick : ( marker ) => {
12471269 const cachedMarker = this . _getClickedMarkerDetails ( marker ) ;
12481270 if ( cachedMarker && cachedMarker . onCalloutTap ) {
12491271 cachedMarker . onCalloutTap ( cachedMarker ) ;
12501272 }
12511273 return true ;
12521274 } ,
1253- } )
1254- ) ;
1255-
1256- const iconFactory = com . mapbox . mapboxsdk . annotations . IconFactory . getInstance ( Application . android . context ) ;
1275+ } ) ;
1276+ this . _mapboxMapInstance . setOnInfoWindowClickListener ( this . onInfoWindowClickListener ) ;
1277+ }
1278+ if ( ! this . iconFactory ) {
1279+ this . iconFactory = com . mapbox . mapboxsdk . annotations . IconFactory . getInstance ( Application . android . context ) ;
1280+ }
1281+ const iconFactory = this . iconFactory ;
12571282
12581283 // if any markers need to be downloaded from the web they need to be available synchronously, so fetch them first before looping
12591284
0 commit comments