-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Gestures.swift
32 lines (29 loc) · 1.05 KB
/
Gestures.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import CoreLocation
import MapLibre
import MapLibreSwiftDSL
import SwiftUI
#Preview("Tappable Circles") {
let tappableID = "simple-circles"
return MapView(styleURL: demoTilesURL) {
// Simple symbol layer demonstration with an icon
CircleStyleLayer(identifier: tappableID, source: pointSource)
.radius(16)
.color(.systemRed)
.strokeWidth(2)
.strokeColor(.white)
SymbolStyleLayer(identifier: "simple-symbols", source: pointSource)
.iconImage(UIImage(systemName: "mappin")!.withRenderingMode(.alwaysTemplate))
.iconColor(.white)
}
.onTapMapGesture(on: [tappableID], onTapChanged: { _, features in
print("Tapped on \(features.first?.description ?? "<nil>")")
})
.ignoresSafeArea(.all)
}
#Preview("Tappable Countries") {
MapView(styleURL: demoTilesURL)
.onTapMapGesture(on: ["countries-fill"], onTapChanged: { _, features in
print("Tapped on \(features.first?.description ?? "<nil>")")
})
.ignoresSafeArea(.all)
}