@@ -34,6 +34,9 @@ struct DisplayClustersView: View {
3434 /// The screen point to perform an identify operation.
3535 @State private var identifyScreenPoint : CGPoint ?
3636
37+ /// The geoelements in the selected cluster.
38+ @State private var geoElements : [ GeoElement ] = [ ]
39+
3740 /// The popup to be shown as the result of the layer identify operation.
3841 @State private var popup : Popup ?
3942
@@ -53,6 +56,9 @@ struct DisplayClustersView: View {
5356 identifyScreenPoint = screenPoint
5457 }
5558 . task ( id: identifyScreenPoint) {
59+ layer? . clearSelection ( )
60+ geoElements. removeAll ( )
61+
5662 guard let identifyScreenPoint,
5763 let layer,
5864 let identifyResult = try ? await proxy. identify (
@@ -63,6 +69,15 @@ struct DisplayClustersView: View {
6369 else { return }
6470 self . popup = identifyResult. popups. first
6571 self . showsPopup = self . popup != nil
72+
73+ guard let identifyGeoElement = identifyResult. geoElements. first else { return }
74+ if let aggregateGeoElement = identifyGeoElement as? AggregateGeoElement {
75+ aggregateGeoElement. isSelected = true
76+ let geoElements = try ? await aggregateGeoElement. geoElements
77+ self . geoElements = geoElements ?? [ ]
78+ } else if let feature = identifyGeoElement as? Feature {
79+ layer. selectFeature ( feature)
80+ }
6681 }
6782 . floatingPanel (
6883 selectedDetent: . constant( . half) ,
@@ -71,7 +86,26 @@ struct DisplayClustersView: View {
7186 ) { [ popup] in
7287 PopupView ( popup: popup!, isPresented: $showsPopup)
7388 . showCloseButton ( true )
74- . padding ( )
89+ . padding ( [ . top, . horizontal] )
90+
91+ if !geoElements. isEmpty {
92+ List {
93+ Section {
94+ ForEach ( Array ( geoElements. enumerated ( ) ) ,
95+ id: \. offset
96+ ) { offset, geoElement in
97+ let name = geoElement. attributes [ " name " ] as? String
98+ Text ( name ?? " Geoelement: \( offset) " )
99+ }
100+ } header: {
101+ Text ( " Geoelements " )
102+ . font ( . title3)
103+ . bold ( )
104+ . foregroundColor ( . primary)
105+ }
106+ }
107+ . listStyle ( . inset)
108+ }
75109 }
76110 . toolbar {
77111 ToolbarItem ( placement: . bottomBar) {
0 commit comments