@@ -259,7 +259,7 @@ export class MapboxView extends MapboxViewBase {
259
259
}
260
260
261
261
if ( ! this . nativeMapView && ( ( this . config && this . config . accessToken ) || ( this . settings && this . settings . accessToken ) ) ) {
262
- this . mapbox = new Mapbox ( ) ;
262
+ this . mapbox = new Mapbox ( this ) ;
263
263
// the NativeScript contentview class extends from Observable to provide the notify method
264
264
// which is the glue that joins this code with whatever callbacks are set in the Mapbox XML
265
265
// tag describing the map.
@@ -429,8 +429,8 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
429
429
430
430
_markerIconDownloadCache = [ ] ;
431
431
432
- constructor ( ) {
433
- super ( ) ;
432
+ constructor ( view ) {
433
+ super ( view ) ;
434
434
435
435
if ( Trace . isEnabled ( ) ) {
436
436
CLog ( CLogTypes . info , 'constructor(): building new Mapbox object.' ) ;
@@ -448,11 +448,6 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
448
448
*/
449
449
setMapboxViewInstance ( mapboxViewInstance : any ) : void { }
450
450
451
- /**
452
- * not used
453
- */
454
- setMapboxMapInstance ( mapboxMapInstance : any ) : void { }
455
-
456
451
/**
457
452
* show the map programmatically.
458
453
*
@@ -981,13 +976,15 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
981
976
CLog ( CLogTypes . info , 'Mapbox:checkForClickEvent(): got click event with point:' , JSON . stringify ( point ) ) ;
982
977
}
983
978
984
- this . eventCallbacks [ 'click' ] . forEach ( ( eventListener ) => {
985
- this . queryRenderedFeatures ( { point, layers : [ eventListener . id ] } ) . then ( ( response ) => {
986
- if ( response . length > 0 ) {
987
- eventListener . callback ( response ) ;
988
- }
979
+ this . eventCallbacks [ 'click' ] &&
980
+ this . eventCallbacks [ 'click' ] . forEach ( ( eventListener ) => {
981
+ this . queryRenderedFeatures ( { point, layers : [ eventListener . id ] } ) . then ( ( response ) => {
982
+ if ( response . length > 0 ) {
983
+ eventListener . callback ( response ) ;
984
+ }
985
+ } ) ;
989
986
} ) ;
990
- } ) ;
987
+ this . view && this . view . notify ( { eventName : 'mapClick' , object : this . view , point } ) ;
991
988
992
989
return false ;
993
990
}
0 commit comments