@@ -73,7 +73,21 @@ export const DEFAULT_HIGHLIGHT_FILL_COLOR = [252, 242, 26, 150];
7373export const DEFAULT_HIGHLIGHT_STROKE_COLOR = [ 252 , 242 , 26 , 255 ] ;
7474export const MAX_CACHE_SIZE_MOBILE = 1 ; // Minimize caching, visible tiles will always be loaded
7575export const DEFAULT_STROKE_WIDTH = 1 ;
76-
76+ export const UUID_CANDIDATES = [
77+ 'ufid' ,
78+ 'UFID' ,
79+ 'id' ,
80+ 'ID' ,
81+ 'fid' ,
82+ 'FID' ,
83+ 'objectid' ,
84+ 'OBJECTID' ,
85+ 'gid' ,
86+ 'GID' ,
87+ 'feature_id' ,
88+ 'FEATURE_ID' ,
89+ '_id'
90+ ] ;
7791/**
7892 * Type for transformRequest returned parameters.
7993 */
@@ -538,6 +552,20 @@ export default class VectorTileLayer extends AbstractTileLayer<VectorTile, Featu
538552 if ( data . tileSource ) {
539553 const hoveredObject = this . hasHoveredObject ( objectHovered ) ;
540554
555+ // Try to infer a stable unique id property from the hovered feature so we can
556+ // highlight the same feature across adjacent tiles. If none is found, rely on
557+ // feature.id when available.
558+ let uniqueIdProperty : string | undefined ;
559+ let highlightedFeatureId : string | number | undefined ;
560+ if ( hoveredObject && hoveredObject . properties ) {
561+ uniqueIdProperty = UUID_CANDIDATES . find (
562+ k => hoveredObject . properties && k in hoveredObject . properties
563+ ) ;
564+ highlightedFeatureId = uniqueIdProperty
565+ ? hoveredObject . properties [ uniqueIdProperty ]
566+ : ( hoveredObject as any ) . id ;
567+ }
568+
541569 const layers = [
542570 new CustomMVTLayer ( {
543571 ...defaultLayerProps ,
@@ -556,7 +584,8 @@ export default class VectorTileLayer extends AbstractTileLayer<VectorTile, Featu
556584 stroked : visConfig . stroked ,
557585
558586 // TODO: this is hard coded, design a UI to allow user assigned unique property id
559- // uniqueIdProperty: 'ufid',
587+ uniqueIdProperty,
588+ highlightedFeatureId,
560589 renderSubLayers : this . renderSubLayers ,
561590 // when radiusUnits is meter
562591 getPointRadiusScaleByZoom : getPropertyByZoom ( visConfig . radiusByZoom , visConfig . radius ) ,
@@ -634,26 +663,7 @@ export default class VectorTileLayer extends AbstractTileLayer<VectorTile, Featu
634663 loadOptions : {
635664 mvt : getLoaderOptions ( ) . mvt
636665 }
637- } ) ,
638- // hover layer
639- ...( hoveredObject
640- ? [
641- new GeoJsonLayer ( {
642- // @ts -expect-error props not typed?
643- ...objectHovered . sourceLayer ?. props ,
644- ...( this . getDefaultHoverLayerProps ( ) as any ) ,
645- visible : true ,
646- wrapLongitude : false ,
647- data : [ hoveredObject ] ,
648- getLineColor : DEFAULT_HIGHLIGHT_STROKE_COLOR ,
649- getFillColor : DEFAULT_HIGHLIGHT_FILL_COLOR ,
650- getLineWidth : visConfig . strokeWidth + 1 ,
651- lineWidthUnits : 'pixels' ,
652- stroked : true ,
653- filled : true
654- } )
655- ]
656- : [ ] )
666+ } )
657667 // ...tileLayerBoundsLayer(defaultLayerProps.id, data),
658668 ] ;
659669
0 commit comments