@@ -1081,38 +1081,28 @@ export class UserInteractions
10811081 : `<div class='flatmap-feature-label'>${ tooltip . join ( '<hr/>' ) } </div>`
10821082 }
10831083
1084- #featureEvent( type : string , feature : MapPointFeature | MapPointFeature [ ] , values = { } )
1085- //================================================================================
1084+ #featureEvent( type : string , feature : MapPointFeature , values = { } )
1085+ //==============================================================
10861086 {
1087- let properties : FlatMapFeatureAnnotation | FlatMapFeatureAnnotation [ ] | null
1088- if ( Array . isArray ( feature ) ) {
1089- const properties_array : FlatMapFeatureAnnotation [ ] = [ ]
1090- const seenModels : string [ ] = [ ]
1091- for ( const f of feature ) {
1092- if ( f . properties . models && ! seenModels . includes ( f . properties . models ) ) {
1093- properties_array . push ( Object . assign ( { } , f . properties , values ) as FlatMapFeatureAnnotation )
1094- seenModels . push ( f . properties . models )
1095- }
1096- }
1097- properties = properties_array
1098- } else {
1099- if ( isMarker ( feature ) ) {
1100- const markerProperties : object = Object . assign ( { } , feature . properties , values )
1101- const markerTerm = markerProperties [ 'models' ]
1102- markerProperties [ 'marker-terms' ] = this . #layerManager. markerTerms ( markerTerm )
1103- return this . #flatmap. markerEvent ( type , + feature . id ! , markerProperties as FlatMapFeatureAnnotation )
1104- } else if ( 'properties' in feature ) {
1105- properties = Object . assign ( { } , feature . properties , values ) as FlatMapFeatureAnnotation
1106- } else {
1107- properties = null
1108- }
1109- }
1110- if ( properties ) {
1087+ let properties : FlatMapFeatureAnnotation
1088+ if ( isMarker ( feature ) ) {
1089+ const markerProperties : object = Object . assign ( { } , feature . properties , values )
1090+ const markerTerm = markerProperties [ 'models' ]
1091+ markerProperties [ 'marker-terms' ] = this . #layerManager. markerTerms ( markerTerm )
1092+ return this . #flatmap. markerEvent ( type , + feature . id ! , markerProperties as FlatMapFeatureAnnotation )
1093+ } else if ( 'properties' in feature ) {
1094+ properties = Object . assign ( { } , feature . properties , values ) as FlatMapFeatureAnnotation
11111095 return this . #flatmap. featureEvent ( type , properties )
11121096 }
11131097 return false
11141098 }
11151099
1100+ #multiFeatureEvent( type : string , featureProperties : FlatMapFeatureAnnotation [ ] )
1101+ //=============================================================================
1102+ {
1103+ return this . #flatmap. featureEvent ( type , featureProperties )
1104+ }
1105+
11161106 #resetFeatureDisplay( )
11171107 //====================
11181108 {
@@ -1390,22 +1380,26 @@ export class UserInteractions
13901380 || ( 'type' in feature . properties
13911381 && feature . properties . type . startsWith ( 'line' ) ) ) )
13921382 if ( lineFeatures . length > 0 ) {
1393- this . #featureEvent ( 'click' , lineFeatures )
1383+ this . #multiFeatureEvent ( 'click' , lineFeatures . map ( f => f . properties ) )
13941384 } else if ( ! ( 'details-layer' in clickedFeature . properties ) ) {
13951385 this . #featureEvent( 'click' , clickedFeature )
13961386 }
1397- } else { // A ``centreline`` map -- we send the click's location along a centreline
1398- const seenFeatures = new Set ( )
1387+ } else { // A ``centreline`` map -- we send the click's location along centrelines
13991388 this . #selectActiveFeatures( event . originalEvent )
14001389 const centreline_click = ( clickedFeature . properties . kind === 'centreline' )
1401- for ( const feature of clickedFeatures ) {
1402- if ( ! seenFeatures . has ( feature . properties . id ) ) {
1403- seenFeatures . add ( feature . properties . id )
1404- if ( ! centreline_click || centreline_click && ( feature . properties . kind === 'centreline' ) ) {
1405- this . #featureEvent( 'click' , feature ,
1406- this . #locationOnLine( + feature . id ! , event . lngLat ) )
1390+ if ( ! centreline_click ) {
1391+ this . #featureEvent( 'click' , clickedFeature )
1392+ } else {
1393+ const seenModels = new Set ( )
1394+ const featureProperties : FlatMapFeatureAnnotation [ ] = [ ]
1395+ for ( const feature of clickedFeatures ) {
1396+ if ( feature . properties . models && ! seenModels . has ( feature . properties . models ) ) {
1397+ const location = this . #locationOnLine( + feature . id ! , event . lngLat )
1398+ featureProperties . push ( Object . assign ( { } , feature . properties , location ) as FlatMapFeatureAnnotation )
1399+ seenModels . add ( feature . properties . models )
14071400 }
14081401 }
1402+ this . #multiFeatureEvent( 'click' , featureProperties )
14091403 }
14101404 }
14111405 if ( this . #flatmap. options . style === FLATMAP_STYLE . FUNCTIONAL
0 commit comments