11import { AltitudeKey , DefaultLatLonKeys , GenericMapPos , LatitudeKey , LongitudeKey , MapPos , MapRange , MapVec , ScreenBounds , ScreenPos , setMapPosKeys } from './index.common' ;
2- import { BaseNative } from '../index.common' ;
2+ import { BaseNative , _createImageSourceFromSrc } from '../index.common' ;
3+ import { Color } from '@nativescript/core' ;
34export { LatitudeKey , LongitudeKey , MapPos , ScreenBounds , ScreenPos , setMapPosKeys } ;
45
56export const CartoMapStyle = {
@@ -11,7 +12,7 @@ export const CartoMapStyle = {
1112 } ,
1213 get DARKMATTER ( ) {
1314 return com . carto . layers . CartoBaseMapStyle . CARTO_BASEMAP_STYLE_DARKMATTER ;
14- }
15+ } ,
1516} ;
1617
1718export const ClickType = {
@@ -26,7 +27,7 @@ export const ClickType = {
2627 } ,
2728 get DUAL ( ) {
2829 return com . carto . ui . ClickType . CLICK_TYPE_DUAL . swigValue ( ) ;
29- }
30+ } ,
3031} ;
3132
3233export class MapBounds < T = DefaultLatLonKeys > extends BaseNative < com . carto . core . MapBounds , { } > {
@@ -64,15 +65,14 @@ export class MapBounds<T = DefaultLatLonKeys> extends BaseNative<com.carto.core.
6465 }
6566}
6667
67-
6868export function fromNativeMapPos < T = DefaultLatLonKeys > ( position : com . carto . core . MapPos ) {
6969 if ( ! position ) {
7070 return null ;
7171 }
7272 return {
7373 [ LatitudeKey ] : position . getY ( ) ,
7474 [ LongitudeKey ] : position . getX ( ) ,
75- [ AltitudeKey ] : position . getZ ( )
75+ [ AltitudeKey ] : position . getZ ( ) ,
7676 } as GenericMapPos < T > ;
7777}
7878export function toNativeMapPos < T = DefaultLatLonKeys > ( position : GenericMapPos < T > | com . carto . core . MapPos , ignoreAltitude = false ) {
@@ -85,14 +85,14 @@ export function toNativeMapPos<T = DefaultLatLonKeys>(position: GenericMapPos<T>
8585 if ( position [ LongitudeKey ] === undefined || position [ LatitudeKey ] === undefined ) {
8686 throw new Error ( `toNativeMapPos: missing lat/lon parameters in ${ position } ` ) ;
8787 }
88- const result = new com . carto . core . MapPos ( position [ LongitudeKey ] , position [ LatitudeKey ] , ( ! ignoreAltitude && position [ AltitudeKey ] > 0 ) ? position [ AltitudeKey ] : 0 ) ;
88+ const result = new com . carto . core . MapPos ( position [ LongitudeKey ] , position [ LatitudeKey ] , ! ignoreAltitude && position [ AltitudeKey ] > 0 ? position [ AltitudeKey ] : 0 ) ;
8989 // ignore z for now as points can get under the map!
9090 return result ;
9191}
9292export function fromNativeScreenPos ( position : com . carto . core . ScreenPos ) {
9393 return {
9494 x : position . getY ( ) ,
95- y : position . getX ( )
95+ y : position . getX ( ) ,
9696 } as ScreenPos ;
9797}
9898export function toNativeScreenPos ( position : ScreenPos ) {
@@ -101,6 +101,72 @@ export function toNativeScreenPos(position: ScreenPos) {
101101 }
102102 return new com . carto . core . ScreenPos ( position . x , position . y ) ;
103103}
104+
105+ // export class Converter {
106+ // NColor = {
107+ // fromNative(value) {
108+ // if (typeof value === 'string') {
109+ // return value;
110+ // }
111+ // return value;
112+ // },
113+ // toNative(value): android.graphics.Color {
114+ // const theColor = value instanceof Color ? value : value._argb ? new Color(value._argb) : new Color(value);
115+ // return theColor.ios;
116+ // },
117+ // };
118+ // Color = {
119+ // fromNative(value) {
120+ // if (typeof value === 'string') {
121+ // return value;
122+ // }
123+ // return new Color((value as com.carto.graphics.Color).getARGB());
124+ // },
125+ // toNative(value) {
126+ // const theColor = value instanceof Color ? value : value._argb ? new Color(value._argb) : new Color(value);
127+ // return new com.carto.graphics.Color(theColor.r, theColor.g, theColor.b, theColor.a);
128+ // },
129+ // };
130+ // MapRange = {
131+ // fromNative(value) {
132+ // return value;
133+ // },
134+ // toNative(value) {
135+ // const theColor = value instanceof Color ? value : value._argb ? new Color(value._argb) : new Color(value);
136+ // return theColor.ios;
137+ // },
138+ // };
139+ // Font = {
140+ // fromNative(value) {
141+ // // no easy from typeface to Font
142+ // return value;
143+ // },
144+ // toNative(value) {
145+ // return value?.getAndroidTypeface();
146+ // },
147+ // };
148+ // CartoImage = {
149+ // fromNative(value) {
150+ // // no easy from typeface to Font
151+ // return value;
152+ // },
153+ // toNative(value) {
154+ // value = _createImageSourceFromSrc(value);
155+ // return com.carto.utils.BitmapUtils.createBitmapFromAndroidBitmap(value.android as android.graphics.Bitmap);
156+ // },
157+ // };
158+ // AndroidEnum(androidEnum) {
159+ // return {
160+ // fromNative(value) {
161+ // // no easy from typeface to Font
162+ // return value.swigValue();
163+ // },
164+ // toNative(value) {
165+ // return androidEnum.swigToEnum(value);
166+ // },
167+ // };
168+ // }
169+ // }
104170export function fromNativeMapRange ( value : NTMapRange ) {
105171 return [ value . getMax ( ) , value . getMin ( ) ] as MapRange ;
106172}
@@ -111,6 +177,7 @@ export function toNativeMapRange(value: MapRange) {
111177 // ignore z for now as points can get under the map!
112178 return new com . carto . core . MapRange ( value [ 0 ] , value [ 1 ] ) ;
113179}
180+
114181export function toNativeMapVec ( value : MapVec | [ number , number , number ] ) {
115182 if ( Array . isArray ( value ) ) {
116183 return new com . carto . core . MapVec ( value [ 0 ] , value [ 1 ] , value [ 2 ] ) ;
@@ -120,11 +187,12 @@ export function toNativeMapVec(value: MapVec | [number, number, number]) {
120187 }
121188 return new com . carto . core . MapVec ( value . x , value . y , value . z ) ;
122189}
190+
123191export function fromNativeMapVec ( value : com . carto . core . MapVec ) {
124192 return {
125193 x : value . getX ( ) ,
126194 y : value . getY ( ) ,
127- z : value . getZ ( )
195+ z : value . getZ ( ) ,
128196 } as MapVec ;
129197}
130198
@@ -151,7 +219,7 @@ export function toNativeMapBounds<T = DefaultLatLonKeys>(bounds: MapBounds<T>) {
151219export function fromNativeScreenBounds ( bounds : com . carto . core . ScreenBounds ) {
152220 return {
153221 min : fromNativeScreenPos ( bounds . getMin ( ) ) ,
154- max : fromNativeScreenPos ( bounds . getMax ( ) )
222+ max : fromNativeScreenPos ( bounds . getMax ( ) ) ,
155223 } as ScreenBounds ;
156224}
157225export function toNativeScreenBounds ( bounds : ScreenBounds ) {
0 commit comments