@@ -179,6 +179,8 @@ export type VectorTileLayerConfig = Merge<
179179 radiusScale ?: string ;
180180 radiusDomain ?: VisualChannelDomain ;
181181 radiusRange ?: any ;
182+
183+ uniqueIdField ?: string | null ;
182184 }
183185> ;
184186
@@ -335,7 +337,9 @@ export default class VectorTileLayer extends AbstractTileLayer<VectorTile, Featu
335337
336338 radiusField : null ,
337339 radiusDomain : [ 0 , 1 ] ,
338- radiusScale : SCALE_TYPES . linear
340+ radiusScale : SCALE_TYPES . linear ,
341+
342+ uniqueIdField : null
339343 } ;
340344 }
341345
@@ -553,15 +557,13 @@ export default class VectorTileLayer extends AbstractTileLayer<VectorTile, Featu
553557 if ( data . tileSource ) {
554558 const hoveredObject = this . hasHoveredObject ( objectHovered ) ;
555559
556- // Try to infer a stable unique id property from the hovered feature so we can
557- // highlight the same feature across adjacent tiles. If none is found, rely on
558- // feature.id when available.
560+ // Resolve unique id property: use configured uniqueIdField if set, otherwise infer
559561 let uniqueIdProperty : string | undefined ;
560562 let highlightedFeatureId : string | number | undefined ;
561563 if ( hoveredObject && hoveredObject . properties ) {
562- uniqueIdProperty = UUID_CANDIDATES . find (
563- k => hoveredObject . properties && k in hoveredObject . properties
564- ) ;
564+ uniqueIdProperty =
565+ this . config . uniqueIdField ??
566+ UUID_CANDIDATES . find ( k => hoveredObject . properties && k in hoveredObject . properties ) ;
565567 highlightedFeatureId = uniqueIdProperty
566568 ? hoveredObject . properties [ uniqueIdProperty ]
567569 : ( hoveredObject as any ) . id ;
@@ -570,7 +572,8 @@ export default class VectorTileLayer extends AbstractTileLayer<VectorTile, Featu
570572 // Build per-tile clipped overlay to draw only the outer stroke of highlighted feature per tile
571573 const perTileOverlays = this . _getPerTileOverlays ( hoveredObject , {
572574 defaultLayerProps,
573- visConfig
575+ visConfig,
576+ uniqueIdProperty
574577 } ) ;
575578
576579 const layers = [
@@ -705,18 +708,15 @@ export default class VectorTileLayer extends AbstractTileLayer<VectorTile, Featu
705708 */
706709 _getPerTileOverlays (
707710 hoveredObject : Feature ,
708- options : { defaultLayerProps : any ; visConfig : any }
711+ options : { defaultLayerProps : any ; visConfig : any ; uniqueIdProperty ?: string }
709712 ) : DeckLayer [ ] {
710713 let perTileOverlays : DeckLayer [ ] = [ ] ;
711714 if ( hoveredObject ) {
712715 try {
713716 const tiles = this . tileDataset ?. getTiles ?.( ) || [ ] ;
714717 // Derive hovered id from hoveredObject
715- const hoveredPid = UUID_CANDIDATES . find (
716- k => hoveredObject ?. properties && k in hoveredObject . properties
717- ) ;
718- const hoveredId = hoveredPid
719- ? String ( hoveredObject ?. properties ?. [ hoveredPid ] )
718+ const hoveredId = options . uniqueIdProperty
719+ ? String ( hoveredObject ?. properties ?. [ options . uniqueIdProperty ] )
720720 : String ( ( hoveredObject as any ) ?. id ) ;
721721
722722 // Group matched fragments by tile id
@@ -727,8 +727,9 @@ export default class VectorTileLayer extends AbstractTileLayer<VectorTile, Featu
727727 if ( ! Array . isArray ( features ) ) continue ;
728728 const tileId = ( tile as any ) . id ;
729729 for ( const f of features ) {
730- const pid = UUID_CANDIDATES . find ( k => f . properties && k in f . properties ) ;
731- const fid = pid ? f . properties ?. [ pid ] : ( f as any ) . id ;
730+ const fid = options . uniqueIdProperty
731+ ? f . properties ?. [ options . uniqueIdProperty ]
732+ : ( f as any ) . id ;
732733 if ( fid !== undefined && String ( fid ) === hoveredId ) {
733734 ( byTile [ tileId ] = byTile [ tileId ] || [ ] ) . push ( f as Feature ) ;
734735 }
0 commit comments