11import {
2+ ClickType ,
23 DefaultLatLonKeys ,
34 MapBounds ,
45 MapPos ,
@@ -16,19 +17,10 @@ import {
1617import { Layer , TileLayer } from '../layers' ;
1718import { IProjection } from '../projections' ;
1819import { restrictedPanningProperty } from './cssproperties' ;
19- import {
20- Layers as BaseLayers ,
21- CartoViewBase ,
22- MapClickedEvent ,
23- MapIdleEvent ,
24- MapInteractionEvent ,
25- MapMovedEvent ,
26- MapReadyEvent ,
27- MapStableEvent
28- } from './index.common' ;
20+ import { Layers as BaseLayers , CartoViewBase , MapClickedEvent , MapIdleEvent , MapInteractionEvent , MapMovedEvent , MapReadyEvent , MapStableEvent } from './index.common' ;
2921
3022import { ImageSource , Property , Utils , booleanConverter } from '@nativescript/core' ;
31- import { MapOptions } from '.' ;
23+ import { MapClickInfo , MapGestureInfo , MapInteractionInfo , MapOptions } from '.' ;
3224import { EPSG4326 } from '../projections/epsg4326' ;
3325export { MapClickedEvent , MapIdleEvent , MapMovedEvent , MapReadyEvent , MapStableEvent } ;
3426
@@ -111,63 +103,54 @@ export class CartoMap<T = DefaultLatLonKeys> extends CartoViewBase {
111103 }
112104 const listener = new com . akylas . carto . additions . AKMapEventListener ( {
113105 onMapIdle : ( ) => {
114- if ( this . hasListeners ( MapIdleEvent ) ) {
115- this . sendEvent ( MapIdleEvent ) ;
116- }
106+ this . sendEvent ( MapIdleEvent ) ;
117107 } ,
118108 onMapMoved : ( userAction : boolean ) => {
119- if ( this . hasListeners ( MapMovedEvent ) ) {
120- this . sendEvent ( MapMovedEvent , { userAction } ) ;
121- }
109+ this . sendEvent < MapGestureInfo > ( MapMovedEvent , { userAction } ) ;
122110 } ,
123111 onMapInteraction : ( interaction : com . carto . ui . MapInteractionInfo , userAction : boolean ) => {
124- if ( this . hasListeners ( MapInteractionEvent ) ) {
125- this . sendEvent ( MapInteractionEvent , {
126- interaction : {
127- userAction,
128- get isAnimationStarted ( ) {
129- return interaction . isAnimationStarted ( ) ;
130- } ,
131- get isPanAction ( ) {
132- return interaction . isPanAction ( ) ;
133- } ,
134- get isRotateAction ( ) {
135- return interaction . isRotateAction ( ) ;
136- } ,
137- get isTiltAction ( ) {
138- return interaction . isTiltAction ( ) ;
139- } ,
140- get isZoomAction ( ) {
141- return interaction . isZoomAction ( ) ;
142- }
112+ this . sendEvent < MapInteractionInfo > ( MapInteractionEvent , {
113+ userAction,
114+ interaction : {
115+ get isAnimationStarted ( ) {
116+ return interaction . isAnimationStarted ( ) ;
117+ } ,
118+ get isPanAction ( ) {
119+ return interaction . isPanAction ( ) ;
120+ } ,
121+ get isRotateAction ( ) {
122+ return interaction . isRotateAction ( ) ;
123+ } ,
124+ get isTiltAction ( ) {
125+ return interaction . isTiltAction ( ) ;
126+ } ,
127+ get isZoomAction ( ) {
128+ return interaction . isZoomAction ( ) ;
143129 }
144- } ) ;
145- }
130+ }
131+ } ) ;
146132 } ,
147133 onMapStable : ( userAction : boolean ) => {
148- if ( this . hasListeners ( MapStableEvent ) ) {
149- this . sendEvent ( MapStableEvent , { userAction } ) ;
150- }
134+ this . sendEvent < MapGestureInfo > ( MapStableEvent , { userAction } ) ;
151135 } ,
152136 onMapClicked : ( mapClickInfo : com . carto . ui . MapClickInfo ) => {
153- if ( this . hasListeners ( MapClickedEvent ) ) {
154- this . sendEvent ( MapClickedEvent , {
155- android : mapClickInfo ,
156- get clickInfo ( ) {
157- return {
158- get duration ( ) {
159- return mapClickInfo . getClickInfo ( ) . getDuration ( ) ;
160- }
161- } ;
162- } ,
163- get clickType ( ) {
164- return mapClickInfo . getClickType ( ) ;
165- } ,
166- get position ( ) {
167- return fromNativeMapPos ( mapClickInfo . getClickPos ( ) ) ;
168- }
169- } ) ;
170- }
137+ this . sendEvent < MapClickInfo > ( MapClickedEvent , {
138+ android : mapClickInfo ,
139+ get clickInfo ( ) {
140+ return {
141+ get duration ( ) : number {
142+ return mapClickInfo . getClickInfo ( ) . getDuration ( ) ;
143+ }
144+ } ;
145+ } ,
146+ get clickType ( ) : ClickType {
147+ // This will return an integer value that can be compared with the actual enum
148+ return mapClickInfo . getClickType ( ) . swigValue ( ) ;
149+ } ,
150+ get position ( ) {
151+ return fromNativeMapPos ( mapClickInfo . getClickPos ( ) ) ;
152+ }
153+ } ) ;
171154 }
172155 } ) ;
173156 this . nativeViewProtected . listener = listener ;
0 commit comments