forked from yandex/mapkit-ios-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapObjectTapListener.swift
47 lines (38 loc) · 1.34 KB
/
MapObjectTapListener.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// MapObjectTapListener.swift
// MapObjects
//
import YandexMapsMobile
final class MapObjectTapListener: NSObject, YMKMapObjectTapListener {
// MARK: - Constructor
init(controller: UIViewController) {
self.controller = controller
}
// MARK: - Public methods
func onMapObjectTap(with mapObject: YMKMapObject, point: YMKPoint) -> Bool {
let alertTitle: String
let alertMessage: String
switch mapObject {
case let polylineObject as YMKPolylineMapObject:
polylineObject.setStrokeColorWith(PolylineColorPalette.color)
alertTitle = "Tapped the polyline"
alertMessage = "Changed color"
case let circleObject as YMKCircleMapObject:
let circleGeometry = GeometryProvider.circleWithRandomRadius
circleObject.geometry = circleGeometry
alertTitle = "Tapped the circle"
alertMessage = "Changed radius to \(circleGeometry.radius)"
default:
alertTitle = "Tapped the placemark"
alertMessage = String(describing: mapObject.userData)
}
AlertPresenter.present(
from: controller,
with: alertTitle,
message: alertMessage
)
return true
}
// MARK: - Private properties
private weak var controller: UIViewController?
}