@@ -41,6 +41,7 @@ import {
4141 hexToRgb ,
4242 getLatLngBounds ,
4343 isPlainObject ,
44+ toArray ,
4445 notNullorUndefined ,
4546 DataContainerInterface ,
4647 getSampleContainerData
@@ -355,8 +356,9 @@ class Layer {
355356 */
356357 get defaultPointColumnPairs ( ) : ColumnPairs {
357358 return {
358- lat : { pair : 'lng' , fieldPairKey : 'lat' } ,
359- lng : { pair : 'lat' , fieldPairKey : 'lng' }
359+ lat : { pair : [ 'lng' , 'altitude' ] , fieldPairKey : 'lat' } ,
360+ lng : { pair : [ 'lat' , 'altitude' ] , fieldPairKey : 'lng' } ,
361+ altitude : { pair : [ 'lng' , 'lat' ] , fieldPairKey : 'altitude' }
360362 } ;
361363 }
362364
@@ -546,11 +548,8 @@ class Layer {
546548
547549 /**
548550 * Assign a field to layer column, return column config
549- * @param key - Column Key
550- * @param field - Selected field
551- * @returns {{} } - Column config
552551 */
553- assignColumn ( key : string , field : Field ) : LayerColumns {
552+ assignColumn ( key : string , field : { name : string ; fieldIdx : number } ) : LayerColumns {
554553 // field value could be null for optional columns
555554 const update = field
556555 ? {
@@ -570,30 +569,41 @@ class Layer {
570569
571570 /**
572571 * Assign a field pair to column config, return column config
573- * @param key - Column Key
574- * @param pair - field Pair
575- * @returns Column config
576572 */
577- assignColumnPairs ( key : string , pair : FieldPair ) : LayerColumns {
573+ assignColumnPairs ( key : string , fieldPairs : FieldPair ) : LayerColumns {
578574 if ( ! this . columnPairs || ! this . columnPairs ?. [ key ] ) {
579575 // should not end in this state
580576 return this . config . columns ;
581577 }
578+ // key = 'lat'
579+ const { pair, fieldPairKey} = this . columnPairs ?. [ key ] ;
582580
583- const { pair : partnerKey , fieldPairKey} = this . columnPairs ?. [ key ] || { } ;
584-
585- if ( ! pair [ fieldPairKey ] ) {
581+ if ( typeof fieldPairKey === 'string' && ! pair [ fieldPairKey ] ) {
586582 // do not allow `key: undefined` to creep into the `updatedColumn` object
587583 return this . config . columns ;
588584 }
589585
590- const { fieldPairKey : partnerFieldPairKey } = this . columnPairs ?. [ partnerKey ] || { } ;
591-
592- return {
586+ // pair = ['lng', 'alt] | 'lng'
587+ const updatedColumn = {
593588 ...this . config . columns ,
594- [ key ] : pair [ fieldPairKey ] ,
595- [ partnerKey ] : pair [ partnerFieldPairKey ]
589+ // @ts -expect-error fieldPairKey can be string[] here?
590+ [ key ] : fieldPairs [ fieldPairKey ]
596591 } ;
592+
593+ const partnerKeys = toArray ( pair ) ;
594+ for ( const partnerKey of partnerKeys ) {
595+ if (
596+ this . config . columns [ partnerKey ] &&
597+ this . columnPairs ?. [ partnerKey ] &&
598+ // @ts -ignore
599+ fieldPairs [ this . columnPairs ?. [ partnerKey ] . fieldPairKey ]
600+ ) {
601+ // @ts -ignore
602+ updatedColumn [ partnerKey ] = fieldPairs [ this . columnPairs ?. [ partnerKey ] . fieldPairKey ] ;
603+ }
604+ }
605+
606+ return updatedColumn ;
597607 }
598608
599609 /**
0 commit comments