@@ -101,6 +101,7 @@ export class ClusteredAnatomicalMarkerLayer
101101 #map: MapLibreMap
102102 #mapTermGraph: MapTermGraph
103103 #markerTerms: Map < string , Set < string > > = new Map ( )
104+ #markerTermsByZoomTerm: Map < string , Set < string > [ ] > = new Map ( )
104105 #multiScaleByZoomTerm: Map < string , boolean [ ] > = new Map ( )
105106 #maxZoom: number
106107 #points: GeoJSON . FeatureCollection = {
@@ -150,7 +151,8 @@ export class ClusteredAnatomicalMarkerLayer
150151 markerTerms ( term : string ) : DatasetMarkerResult [ ]
151152 //==============================================
152153 {
153- const terms = [ ...( this . #markerTerms. get ( term ) || [ ] ) . values ( ) ]
154+ const zoomLevel = Math . floor ( this . #map. getZoom ( ) )
155+ const terms = [ ...( this . #markerTermsByZoomTerm. get ( term ) [ zoomLevel ] || [ ] ) . values ( ) ]
154156 return terms . map ( term => {
155157 let label : string = term
156158 const termFeatures = this . #flatmap. modelFeatureIds ( term )
@@ -230,23 +232,39 @@ export class ClusteredAnatomicalMarkerLayer
230232 for ( const cluster of clusteredSet . clusters ) {
231233 let zoomDatasets = this . #datasetsByZoomTerm. get ( cluster . term )
232234 let zoomMultiscale = this . #multiScaleByZoomTerm. get ( cluster . term )
235+ let zoomMarkerTerms = this . #markerTermsByZoomTerm. get ( cluster . term )
233236 if ( ! zoomDatasets ) {
234237 zoomDatasets = [ ]
235238 zoomMultiscale = [ ]
239+ zoomMarkerTerms = [ ]
236240 for ( let n = 0 ; n <= MAX_MARKER_ZOOM ; n += 1 ) {
237241 zoomDatasets . push ( new Set < string > ( ) )
238242 zoomMultiscale . push ( false )
243+ zoomMarkerTerms . push ( new Set < string > ( ) )
239244 }
240245 this . #datasetsByZoomTerm. set ( cluster . term , zoomDatasets )
241246 this . #multiScaleByZoomTerm. set ( cluster . term , zoomMultiscale )
247+ this . #markerTermsByZoomTerm. set ( cluster . term , zoomMarkerTerms )
242248 }
243249 for ( let zoom = cluster . minZoom ; zoom < cluster . maxZoom ; zoom += 1 ) {
244250 zoomDatasets [ zoom ] . add ( cluster . datasetId )
245251 zoomMultiscale ! [ zoom ] ||= ( this . #kindByDataset. get ( cluster . datasetId ) === 'multiscale' )
252+ const descendents = clusteredSet . descendents . get ( cluster . term )
253+ if ( descendents ) {
254+ for ( const descendent of descendents . values ( ) ) {
255+ zoomMarkerTerms [ zoom ] . add ( descendent )
256+ }
257+ }
246258 }
247259 if ( cluster . maxZoom === MAX_MARKER_ZOOM ) {
248260 zoomDatasets [ MAX_MARKER_ZOOM ] . add ( cluster . datasetId )
249261 zoomMultiscale ! [ MAX_MARKER_ZOOM ] ||= ( this . #kindByDataset. get ( cluster . datasetId ) === 'multiscale' )
262+ const descendents = clusteredSet . descendents . get ( cluster . term )
263+ if ( descendents ) {
264+ for ( const descendent of descendents . values ( ) ) {
265+ zoomMarkerTerms [ MAX_MARKER_ZOOM ] . add ( descendent )
266+ }
267+ }
250268 let datasetFeatureIds = this . #datasetFeatureIds. get ( cluster . datasetId )
251269 if ( ! datasetFeatureIds ) {
252270 datasetFeatureIds = new Set ( )
0 commit comments