@@ -1081,38 +1081,28 @@ export class UserInteractions
1081
1081
: `<div class='flatmap-feature-label'>${ tooltip . join ( '<hr/>' ) } </div>`
1082
1082
}
1083
1083
1084
- #featureEvent( type : string , feature : MapPointFeature | MapPointFeature [ ] , values = { } )
1085
- //================================================================================
1084
+ #featureEvent( type : string , feature : MapPointFeature , values = { } )
1085
+ //==============================================================
1086
1086
{
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
1111
1095
return this . #flatmap. featureEvent ( type , properties )
1112
1096
}
1113
1097
return false
1114
1098
}
1115
1099
1100
+ #multiFeatureEvent( type : string , featureProperties : FlatMapFeatureAnnotation [ ] )
1101
+ //=============================================================================
1102
+ {
1103
+ return this . #flatmap. featureEvent ( type , featureProperties )
1104
+ }
1105
+
1116
1106
#resetFeatureDisplay( )
1117
1107
//====================
1118
1108
{
@@ -1390,22 +1380,26 @@ export class UserInteractions
1390
1380
|| ( 'type' in feature . properties
1391
1381
&& feature . properties . type . startsWith ( 'line' ) ) ) )
1392
1382
if ( lineFeatures . length > 0 ) {
1393
- this . #featureEvent ( 'click' , lineFeatures )
1383
+ this . #multiFeatureEvent ( 'click' , lineFeatures . map ( f => f . properties ) )
1394
1384
} else if ( ! ( 'details-layer' in clickedFeature . properties ) ) {
1395
1385
this . #featureEvent( 'click' , clickedFeature )
1396
1386
}
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
1399
1388
this . #selectActiveFeatures( event . originalEvent )
1400
1389
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 )
1407
1400
}
1408
1401
}
1402
+ this . #multiFeatureEvent( 'click' , featureProperties )
1409
1403
}
1410
1404
}
1411
1405
if ( this . #flatmap. options . style === FLATMAP_STYLE . FUNCTIONAL
0 commit comments