@exterio/react-native-yamap-lite 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +510 -0
- package/YamapLite.podspec +21 -0
- package/android/build.gradle +101 -0
- package/android/gradle.properties +14 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/yamaplite/ClusteredYamapLiteViewManager.kt +181 -0
- package/android/src/main/java/com/yamaplite/Components/ClusteredYamapLiteView.kt +169 -0
- package/android/src/main/java/com/yamaplite/Components/YamapLiteCircleView.kt +145 -0
- package/android/src/main/java/com/yamaplite/Components/YamapLiteMarkerView.kt +214 -0
- package/android/src/main/java/com/yamaplite/Components/YamapLitePolygon.kt +149 -0
- package/android/src/main/java/com/yamaplite/Components/YamapLitePolyline.kt +171 -0
- package/android/src/main/java/com/yamaplite/Components/YamapLiteView.kt +678 -0
- package/android/src/main/java/com/yamaplite/Events/CameraPositionChangeEvent.kt +38 -0
- package/android/src/main/java/com/yamaplite/Events/MapLoadEvent.kt +34 -0
- package/android/src/main/java/com/yamaplite/Events/PressEvent.kt +24 -0
- package/android/src/main/java/com/yamaplite/Utils/ImageCache.kt +45 -0
- package/android/src/main/java/com/yamaplite/Utils/PointParser.kt +39 -0
- package/android/src/main/java/com/yamaplite/Utils/ResolveImageHelper.kt +122 -0
- package/android/src/main/java/com/yamaplite/Utils/YamapUtils.kt +169 -0
- package/android/src/main/java/com/yamaplite/YamapLiteCircleViewManager.kt +67 -0
- package/android/src/main/java/com/yamaplite/YamapLiteMarkerViewManager.kt +82 -0
- package/android/src/main/java/com/yamaplite/YamapLitePackage.kt +41 -0
- package/android/src/main/java/com/yamaplite/YamapLitePolygonViewManager.kt +61 -0
- package/android/src/main/java/com/yamaplite/YamapLitePolylineViewManager.kt +75 -0
- package/android/src/main/java/com/yamaplite/YamapLiteViewManager.kt +176 -0
- package/ios/ClusteredYamapLiteView.h +15 -0
- package/ios/ClusteredYamapLiteView.mm +325 -0
- package/ios/ClusteredYamapLiteViewManager.mm +17 -0
- package/ios/Components/Circle.swift +108 -0
- package/ios/Components/ClusteredYamap.swift +190 -0
- package/ios/Components/Marker.swift +187 -0
- package/ios/Components/Polygon.swift +108 -0
- package/ios/Components/Polyline.swift +125 -0
- package/ios/Components/Yamap.swift +585 -0
- package/ios/Listeners/CameraListener.swift +54 -0
- package/ios/Listeners/ClusterListener.swift +38 -0
- package/ios/Listeners/MapInputListener.swift +35 -0
- package/ios/Listeners/MapLoadListener.swift +35 -0
- package/ios/Listeners/MapObjectTap.swift +12 -0
- package/ios/Listeners/UserLocationObjectListener.swift +29 -0
- package/ios/Models/YamapModels.swift +77 -0
- package/ios/Utils/ImageCache.swift +20 -0
- package/ios/Utils/PointsEqual.h +45 -0
- package/ios/Utils/ResolveImageHelper.swift +142 -0
- package/ios/YamapLiteCircleView.h +15 -0
- package/ios/YamapLiteCircleView.mm +102 -0
- package/ios/YamapLiteMarkerView.h +15 -0
- package/ios/YamapLiteMarkerView.mm +102 -0
- package/ios/YamapLitePolygonView.h +15 -0
- package/ios/YamapLitePolygonView.mm +120 -0
- package/ios/YamapLitePolylineView.h +15 -0
- package/ios/YamapLitePolylineView.mm +115 -0
- package/ios/YamapLiteView.h +15 -0
- package/ios/YamapLiteView.mm +361 -0
- package/ios/YamapLiteViewManager.mm +17 -0
- package/ios/YamapUtils.h +5 -0
- package/ios/YamapUtils.mm +205 -0
- package/lib/module/@types/index.js +8 -0
- package/lib/module/@types/index.js.map +1 -0
- package/lib/module/ClusteredYamapLiteViewNativeComponent.ts +98 -0
- package/lib/module/Components/Circle.js +20 -0
- package/lib/module/Components/Circle.js.map +1 -0
- package/lib/module/Components/ClusteredYamap.js +133 -0
- package/lib/module/Components/ClusteredYamap.js.map +1 -0
- package/lib/module/Components/Marker.js +40 -0
- package/lib/module/Components/Marker.js.map +1 -0
- package/lib/module/Components/Polygon.js +25 -0
- package/lib/module/Components/Polygon.js.map +1 -0
- package/lib/module/Components/Polyline.js +25 -0
- package/lib/module/Components/Polyline.js.map +1 -0
- package/lib/module/Components/Yamap.js +124 -0
- package/lib/module/Components/Yamap.js.map +1 -0
- package/lib/module/Components/index.js +9 -0
- package/lib/module/Components/index.js.map +1 -0
- package/lib/module/NativeYamapUtils.js +5 -0
- package/lib/module/NativeYamapUtils.js.map +1 -0
- package/lib/module/Utils/YamapUtils.js +14 -0
- package/lib/module/Utils/YamapUtils.js.map +1 -0
- package/lib/module/YamapCircleViewNativeComponent.ts +28 -0
- package/lib/module/YamapLiteViewNativeComponent.ts +93 -0
- package/lib/module/YamapMarkerViewNativeComponent.ts +32 -0
- package/lib/module/YamapPolygonViewNativeComponent.ts +28 -0
- package/lib/module/YamapPolylineViewNativeComponent.ts +31 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/@types/index.d.ts +257 -0
- package/lib/typescript/src/@types/index.d.ts.map +1 -0
- package/lib/typescript/src/ClusteredYamapLiteViewNativeComponent.d.ts +82 -0
- package/lib/typescript/src/ClusteredYamapLiteViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/Components/Circle.d.ts +4 -0
- package/lib/typescript/src/Components/Circle.d.ts.map +1 -0
- package/lib/typescript/src/Components/ClusteredYamap.d.ts +3 -0
- package/lib/typescript/src/Components/ClusteredYamap.d.ts.map +1 -0
- package/lib/typescript/src/Components/Marker.d.ts +3 -0
- package/lib/typescript/src/Components/Marker.d.ts.map +1 -0
- package/lib/typescript/src/Components/Polygon.d.ts +4 -0
- package/lib/typescript/src/Components/Polygon.d.ts.map +1 -0
- package/lib/typescript/src/Components/Polyline.d.ts +4 -0
- package/lib/typescript/src/Components/Polyline.d.ts.map +1 -0
- package/lib/typescript/src/Components/Yamap.d.ts +3 -0
- package/lib/typescript/src/Components/Yamap.d.ts.map +1 -0
- package/lib/typescript/src/Components/index.d.ts +7 -0
- package/lib/typescript/src/Components/index.d.ts.map +1 -0
- package/lib/typescript/src/NativeYamapUtils.d.ts +30 -0
- package/lib/typescript/src/NativeYamapUtils.d.ts.map +1 -0
- package/lib/typescript/src/Utils/YamapUtils.d.ts +27 -0
- package/lib/typescript/src/Utils/YamapUtils.d.ts.map +1 -0
- package/lib/typescript/src/YamapCircleViewNativeComponent.d.ts +20 -0
- package/lib/typescript/src/YamapCircleViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/YamapLiteViewNativeComponent.d.ts +80 -0
- package/lib/typescript/src/YamapLiteViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/YamapMarkerViewNativeComponent.d.ts +25 -0
- package/lib/typescript/src/YamapMarkerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/YamapPolygonViewNativeComponent.d.ts +20 -0
- package/lib/typescript/src/YamapPolygonViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/YamapPolylineViewNativeComponent.d.ts +23 -0
- package/lib/typescript/src/YamapPolylineViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +189 -0
- package/src/@types/index.ts +314 -0
- package/src/ClusteredYamapLiteViewNativeComponent.ts +98 -0
- package/src/Components/Circle.tsx +22 -0
- package/src/Components/ClusteredYamap.tsx +194 -0
- package/src/Components/Marker.tsx +50 -0
- package/src/Components/Polygon.tsx +27 -0
- package/src/Components/Polyline.tsx +27 -0
- package/src/Components/Yamap.tsx +176 -0
- package/src/Components/index.ts +6 -0
- package/src/NativeYamapUtils.ts +47 -0
- package/src/Utils/YamapUtils.ts +63 -0
- package/src/YamapCircleViewNativeComponent.ts +28 -0
- package/src/YamapLiteViewNativeComponent.ts +93 -0
- package/src/YamapMarkerViewNativeComponent.ts +32 -0
- package/src/YamapPolygonViewNativeComponent.ts +28 -0
- package/src/YamapPolylineViewNativeComponent.ts +31 -0
- package/src/index.tsx +5 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
package com.yamaplite.components
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.graphics.Color
|
|
5
|
+
import android.view.ViewGroup
|
|
6
|
+
import com.facebook.react.bridge.ReactContext
|
|
7
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
8
|
+
import com.yamaplite.events.PressEvent
|
|
9
|
+
import com.yandex.mapkit.geometry.LinearRing
|
|
10
|
+
import com.yandex.mapkit.geometry.Point
|
|
11
|
+
import com.yandex.mapkit.geometry.Polygon
|
|
12
|
+
import com.yandex.mapkit.map.MapObject
|
|
13
|
+
import com.yandex.mapkit.map.MapObjectTapListener
|
|
14
|
+
import com.yandex.mapkit.map.PolygonMapObject
|
|
15
|
+
import com.yandex.mapkit.mapview.MapView
|
|
16
|
+
|
|
17
|
+
class YamapPolygon(context: Context?) : ViewGroup(context), MapObjectTapListener {
|
|
18
|
+
var polygon = Polygon()
|
|
19
|
+
|
|
20
|
+
var rnMapObject: MapObject? = null
|
|
21
|
+
|
|
22
|
+
private var mapView: MapView? = null
|
|
23
|
+
|
|
24
|
+
private var fillColor = Color.BLACK
|
|
25
|
+
|
|
26
|
+
private var strokeColor = Color.BLACK
|
|
27
|
+
|
|
28
|
+
private var strokeWidth = 1f
|
|
29
|
+
|
|
30
|
+
private var zIndex = 1f
|
|
31
|
+
|
|
32
|
+
private var points: ArrayList<Point> = ArrayList()
|
|
33
|
+
|
|
34
|
+
private var innerRings: ArrayList<ArrayList<Point>>? = ArrayList()
|
|
35
|
+
|
|
36
|
+
private var handled = true
|
|
37
|
+
|
|
38
|
+
init {
|
|
39
|
+
polygon = Polygon(LinearRing(points), emptyList())
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
fun setFillColor(_color: Int) {
|
|
43
|
+
fillColor = _color
|
|
44
|
+
updatePolygon()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
fun setStrokeColor(_color: Int) {
|
|
48
|
+
strokeColor = _color
|
|
49
|
+
updatePolygon()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fun setStrokeWidth(_width: Float) {
|
|
53
|
+
strokeWidth = _width
|
|
54
|
+
updatePolygon()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fun setZIndex(_zIndex: Float) {
|
|
58
|
+
zIndex = _zIndex
|
|
59
|
+
updatePolygon()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fun setPoints(_points: ArrayList<Point>) {
|
|
63
|
+
points = _points
|
|
64
|
+
updateGeometry()
|
|
65
|
+
if (rnMapObject == null && mapView != null && isGeometryValid()) {
|
|
66
|
+
addToMap(mapView!!)
|
|
67
|
+
} else {
|
|
68
|
+
updatePolygon()
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
fun setInnerRings(_innerRings: ArrayList<ArrayList<Point>>) {
|
|
73
|
+
innerRings = _innerRings
|
|
74
|
+
updateGeometry()
|
|
75
|
+
updatePolygon()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private fun List<Point>.isValidRing(): Boolean =
|
|
79
|
+
size >= 3 && all { it.latitude.isFinite() && it.longitude.isFinite() }
|
|
80
|
+
|
|
81
|
+
private fun isGeometryValid(): Boolean = points.isValidRing()
|
|
82
|
+
|
|
83
|
+
fun setHandled(_handled: Boolean) {
|
|
84
|
+
handled = _handled
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {}
|
|
88
|
+
|
|
89
|
+
private fun updatePolygon() {
|
|
90
|
+
if (rnMapObject != null) {
|
|
91
|
+
val polygonMapObject = rnMapObject as PolygonMapObject
|
|
92
|
+
polygonMapObject.geometry = polygon
|
|
93
|
+
polygonMapObject.zIndex = zIndex
|
|
94
|
+
polygonMapObject.fillColor = fillColor
|
|
95
|
+
polygonMapObject.strokeColor = strokeColor
|
|
96
|
+
polygonMapObject.strokeWidth = strokeWidth
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
private fun updateGeometry() {
|
|
100
|
+
if (!isGeometryValid()) return
|
|
101
|
+
val ring = LinearRing(points)
|
|
102
|
+
val unwrappedInnerRings =
|
|
103
|
+
(innerRings ?: ArrayList()).filter { it.isValidRing() }.map { LinearRing(it) }
|
|
104
|
+
polygon = Polygon(ring, unwrappedInnerRings)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
override fun onMapObjectTap(mapObject: MapObject, point: Point): Boolean {
|
|
108
|
+
val reactContext = context as? ReactContext
|
|
109
|
+
if (reactContext == null) {
|
|
110
|
+
return false
|
|
111
|
+
}
|
|
112
|
+
val viewId = getId()
|
|
113
|
+
val surfaceId = UIManagerHelper.getSurfaceId(reactContext)
|
|
114
|
+
val eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, viewId)
|
|
115
|
+
if (eventDispatcher != null) {
|
|
116
|
+
val event = PressEvent(surfaceId, viewId, "onPolygonPress", point)
|
|
117
|
+
eventDispatcher.dispatchEvent(event)
|
|
118
|
+
}
|
|
119
|
+
return handled
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
fun setMapObject(obj: MapObject) {
|
|
123
|
+
if (obj is PolygonMapObject) {
|
|
124
|
+
rnMapObject = obj
|
|
125
|
+
rnMapObject!!.addTapListener(this)
|
|
126
|
+
updatePolygon()
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
fun addToMap(mapView: MapView) {
|
|
131
|
+
this.mapView = mapView
|
|
132
|
+
if (!isGeometryValid()) {
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
val polygonObject = mapView.mapWindow.map.mapObjects.addPolygon(polygon)
|
|
136
|
+
rnMapObject = polygonObject
|
|
137
|
+
polygonObject.addTapListener(this)
|
|
138
|
+
updatePolygon()
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
fun removeFromMap(mapView: MapView) {
|
|
142
|
+
rnMapObject?.let {
|
|
143
|
+
if (it.isValid) {
|
|
144
|
+
mapView.mapWindow.map.mapObjects.remove(it)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
rnMapObject = null
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
package com.yamaplite.components
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.graphics.Color
|
|
5
|
+
import android.view.ViewGroup
|
|
6
|
+
import com.facebook.react.bridge.ReactContext
|
|
7
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
8
|
+
import com.yamaplite.events.PressEvent
|
|
9
|
+
import com.yandex.mapkit.geometry.Point
|
|
10
|
+
import com.yandex.mapkit.geometry.Polyline
|
|
11
|
+
import com.yandex.mapkit.map.MapObject
|
|
12
|
+
import com.yandex.mapkit.map.MapObjectTapListener
|
|
13
|
+
import com.yandex.mapkit.map.PolylineMapObject
|
|
14
|
+
import com.yandex.mapkit.mapview.MapView
|
|
15
|
+
|
|
16
|
+
class YamapPolyline(context: Context?) : ViewGroup(context), MapObjectTapListener {
|
|
17
|
+
var polyline: Polyline
|
|
18
|
+
|
|
19
|
+
var rnMapObject: MapObject? = null
|
|
20
|
+
|
|
21
|
+
private var mapView: MapView? = null
|
|
22
|
+
|
|
23
|
+
private var strokeColor = Color.BLACK
|
|
24
|
+
|
|
25
|
+
private var strokeWidth = 1f
|
|
26
|
+
|
|
27
|
+
private var outlineColor = Color.BLACK
|
|
28
|
+
|
|
29
|
+
private var zIndex = 1f
|
|
30
|
+
|
|
31
|
+
private var dashLength = 1f
|
|
32
|
+
|
|
33
|
+
private var gapLength = 0f
|
|
34
|
+
|
|
35
|
+
private var outlineWidth = 0f
|
|
36
|
+
|
|
37
|
+
private var dashOffset = 0f
|
|
38
|
+
|
|
39
|
+
private var points: ArrayList<Point> = ArrayList()
|
|
40
|
+
|
|
41
|
+
private var handled = true
|
|
42
|
+
|
|
43
|
+
init {
|
|
44
|
+
polyline = Polyline(points)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {}
|
|
48
|
+
|
|
49
|
+
fun setStrokeColor(_color: Int) {
|
|
50
|
+
strokeColor = _color
|
|
51
|
+
updatePolyline()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fun setStrokeWidth(_width: Float) {
|
|
55
|
+
strokeWidth = _width
|
|
56
|
+
updatePolyline()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
fun setOutlineColor(_color: Int) {
|
|
60
|
+
outlineColor = _color
|
|
61
|
+
updatePolyline()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
fun setZIndex(_zIndex: Float) {
|
|
65
|
+
zIndex = _zIndex
|
|
66
|
+
updatePolyline()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
fun setDashLength(_dashLength: Float) {
|
|
70
|
+
dashLength = _dashLength
|
|
71
|
+
updatePolyline()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
fun setGapLength(_gapLength: Float) {
|
|
75
|
+
gapLength = _gapLength
|
|
76
|
+
updatePolyline()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
fun setOutlineWidth(_outlineWidth: Float) {
|
|
80
|
+
outlineWidth = _outlineWidth
|
|
81
|
+
updatePolyline()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
fun setDashOffset(_dashOffset: Float) {
|
|
85
|
+
dashOffset = _dashOffset
|
|
86
|
+
updatePolyline()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
fun setPoints(_points: ArrayList<Point>) {
|
|
90
|
+
points = _points
|
|
91
|
+
updateGeometry()
|
|
92
|
+
if (rnMapObject == null && mapView != null && isGeometryValid()) {
|
|
93
|
+
addToMap(mapView!!)
|
|
94
|
+
} else {
|
|
95
|
+
updatePolyline()
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private fun isGeometryValid(): Boolean =
|
|
100
|
+
points.size >= 2 && points.all { it.latitude.isFinite() && it.longitude.isFinite() }
|
|
101
|
+
|
|
102
|
+
fun setHandled(_handled: Boolean) {
|
|
103
|
+
handled = _handled
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private fun updatePolyline() {
|
|
107
|
+
if (rnMapObject != null) {
|
|
108
|
+
val polylineMapObject = rnMapObject as PolylineMapObject
|
|
109
|
+
polylineMapObject.geometry = polyline
|
|
110
|
+
polylineMapObject.zIndex = zIndex
|
|
111
|
+
polylineMapObject.setStrokeColor(strokeColor)
|
|
112
|
+
polylineMapObject.strokeWidth = strokeWidth
|
|
113
|
+
polylineMapObject.dashLength = dashLength
|
|
114
|
+
polylineMapObject.gapLength = gapLength
|
|
115
|
+
polylineMapObject.dashOffset = dashOffset
|
|
116
|
+
polylineMapObject.outlineWidth = outlineWidth
|
|
117
|
+
if (outlineWidth > 0) {
|
|
118
|
+
polylineMapObject.outlineColor = outlineColor
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private fun updateGeometry() {
|
|
124
|
+
if (isGeometryValid()) {
|
|
125
|
+
polyline = Polyline(points)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
fun setMapObject(obj: MapObject) {
|
|
130
|
+
if (obj is PolylineMapObject) {
|
|
131
|
+
rnMapObject = obj
|
|
132
|
+
rnMapObject!!.addTapListener(this)
|
|
133
|
+
updatePolyline()
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
override fun onMapObjectTap(mapObject: MapObject, point: Point): Boolean {
|
|
138
|
+
val reactContext = context as? ReactContext
|
|
139
|
+
if (reactContext == null) {
|
|
140
|
+
return false
|
|
141
|
+
}
|
|
142
|
+
val viewId = getId()
|
|
143
|
+
val surfaceId = UIManagerHelper.getSurfaceId(reactContext)
|
|
144
|
+
val eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, viewId)
|
|
145
|
+
if (eventDispatcher != null) {
|
|
146
|
+
val event = PressEvent(surfaceId, viewId, "onPolylinePress", point)
|
|
147
|
+
eventDispatcher.dispatchEvent(event)
|
|
148
|
+
}
|
|
149
|
+
return handled
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
fun addToMap(mapView: MapView) {
|
|
153
|
+
this.mapView = mapView
|
|
154
|
+
if (!isGeometryValid()) {
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
val polylineObject = mapView.mapWindow.map.mapObjects.addPolyline(polyline)
|
|
158
|
+
rnMapObject = polylineObject
|
|
159
|
+
polylineObject.addTapListener(this)
|
|
160
|
+
updatePolyline()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
fun removeFromMap(mapView: MapView) {
|
|
164
|
+
rnMapObject?.let {
|
|
165
|
+
if (it.isValid) {
|
|
166
|
+
mapView.mapWindow.map.mapObjects.remove(it)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
rnMapObject = null
|
|
170
|
+
}
|
|
171
|
+
}
|