@lugg/maps 1.0.0-beta.2 → 1.0.0-beta.21
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/README.md +3 -0
- package/android/src/main/java/com/luggmaps/LuggCalloutView.kt +9 -2
- package/android/src/main/java/com/luggmaps/LuggCalloutViewManager.kt +4 -3
- package/android/src/main/java/com/luggmaps/LuggCircleView.kt +85 -0
- package/android/src/main/java/com/luggmaps/LuggCircleViewManager.kt +79 -0
- package/android/src/main/java/com/luggmaps/LuggGroundOverlayView.kt +81 -0
- package/android/src/main/java/com/luggmaps/LuggGroundOverlayViewManager.kt +82 -0
- package/android/src/main/java/com/luggmaps/LuggMapView.kt +90 -0
- package/android/src/main/java/com/luggmaps/LuggMapViewManager.kt +45 -0
- package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +27 -2
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +30 -2
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +13 -0
- package/android/src/main/java/com/luggmaps/LuggPackage.kt +4 -1
- package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +3 -23
- package/android/src/main/java/com/luggmaps/LuggTileOverlayView.kt +92 -0
- package/android/src/main/java/com/luggmaps/LuggTileOverlayViewManager.kt +80 -0
- package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +737 -37
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +15 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +65 -11
- package/android/src/main/java/com/luggmaps/events/CirclePressEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/events/GroundOverlayPressEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/events/TileOverlayPressEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/extensions/ViewExtensions.kt +11 -0
- package/ios/LuggCalloutView.h +1 -1
- package/ios/LuggCalloutView.mm +21 -11
- package/ios/LuggCircleView.h +31 -0
- package/ios/LuggCircleView.mm +133 -0
- package/ios/LuggGroundOverlayView.h +30 -0
- package/ios/LuggGroundOverlayView.mm +125 -0
- package/ios/LuggMapView.mm +254 -4
- package/ios/LuggMapWrapperView.h +5 -0
- package/ios/LuggMapWrapperView.mm +18 -0
- package/ios/LuggMarkerView.h +3 -0
- package/ios/LuggMarkerView.mm +25 -0
- package/ios/LuggTileOverlayView.h +31 -0
- package/ios/LuggTileOverlayView.mm +130 -0
- package/ios/core/AppleMapProvider.h +8 -0
- package/ios/core/AppleMapProvider.mm +663 -29
- package/ios/core/AppleStaticMapProvider.h +14 -0
- package/ios/core/AppleStaticMapProvider.mm +159 -0
- package/ios/core/GMSPolylineAnimator.m +46 -18
- package/ios/core/GoogleMapProvider.h +10 -0
- package/ios/core/GoogleMapProvider.mm +430 -51
- package/ios/core/GoogleStaticMapProvider.h +21 -0
- package/ios/core/GoogleStaticMapProvider.mm +213 -0
- package/ios/core/MKPolylineAnimator.m +67 -43
- package/ios/core/MapProviderDelegate.h +27 -1
- package/ios/core/StaticMapProviderBase.h +75 -0
- package/ios/core/StaticMapProviderBase.mm +845 -0
- package/ios/events/CameraIdleEvent.h +4 -2
- package/ios/events/CameraMoveEvent.h +4 -2
- package/ios/events/CirclePressEvent.h +22 -0
- package/ios/events/GroundOverlayPressEvent.h +22 -0
- package/ios/events/LongPressEvent.h +4 -2
- package/ios/events/MarkerDragEvent.h +12 -6
- package/ios/events/MarkerPressEvent.h +4 -2
- package/ios/events/PolygonPressEvent.h +4 -2
- package/ios/events/PressEvent.h +4 -2
- package/ios/events/ReadyEvent.h +4 -2
- package/ios/events/TileOverlayPressEvent.h +22 -0
- package/ios/extensions/MKMapView+Zoom.h +20 -0
- package/ios/extensions/MKMapView+Zoom.m +28 -18
- package/ios/extensions/UIView+Snapshot.h +16 -0
- package/ios/extensions/UIView+Snapshot.m +27 -0
- package/lib/module/MapProvider.web.js +4 -1
- package/lib/module/MapProvider.web.js.map +1 -1
- package/lib/module/MapView.js +19 -1
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +30 -22
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/Circle.js +46 -0
- package/lib/module/components/Circle.js.map +1 -0
- package/lib/module/components/Circle.types.js +4 -0
- package/lib/module/components/Circle.types.js.map +1 -0
- package/lib/module/components/Circle.web.js +79 -0
- package/lib/module/components/Circle.web.js.map +1 -0
- package/lib/module/components/GeoJson.js +3 -3
- package/lib/module/components/GeoJson.js.map +1 -1
- package/lib/module/components/GroundOverlay.js +45 -0
- package/lib/module/components/GroundOverlay.js.map +1 -0
- package/lib/module/components/GroundOverlay.types.js +4 -0
- package/lib/module/components/GroundOverlay.types.js.map +1 -0
- package/lib/module/components/GroundOverlay.web.js +77 -0
- package/lib/module/components/GroundOverlay.web.js.map +1 -0
- package/lib/module/components/Marker.js +22 -4
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.web.js +23 -10
- package/lib/module/components/Marker.web.js.map +1 -1
- package/lib/module/components/Polygon.web.js +3 -3
- package/lib/module/components/Polygon.web.js.map +1 -1
- package/lib/module/components/Polyline.web.js +6 -12
- package/lib/module/components/Polyline.web.js.map +1 -1
- package/lib/module/components/TileOverlay.js +44 -0
- package/lib/module/components/TileOverlay.js.map +1 -0
- package/lib/module/components/TileOverlay.types.js +4 -0
- package/lib/module/components/TileOverlay.types.js.map +1 -0
- package/lib/module/components/TileOverlay.web.js +69 -0
- package/lib/module/components/TileOverlay.web.js.map +1 -0
- package/lib/module/components/index.js +3 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/index.web.js +3 -0
- package/lib/module/components/index.web.js.map +1 -1
- package/lib/module/fabric/LuggCalloutViewNativeComponent.ts +1 -1
- package/lib/module/fabric/LuggCircleViewNativeComponent.ts +25 -0
- package/lib/module/fabric/LuggGroundOverlayViewNativeComponent.ts +29 -0
- package/lib/module/fabric/LuggMapViewNativeComponent.ts +16 -5
- package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +14 -2
- package/lib/module/fabric/LuggTileOverlayViewNativeComponent.ts +30 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +3 -0
- package/lib/module/index.web.js.map +1 -1
- package/lib/typescript/src/MapProvider.web.d.ts +3 -2
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
- package/lib/typescript/src/MapView.d.ts +1 -1
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +60 -1
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts +1 -1
- package/lib/typescript/src/MapView.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Circle.d.ts +10 -0
- package/lib/typescript/src/components/Circle.d.ts.map +1 -0
- package/lib/typescript/src/components/Circle.types.d.ts +33 -0
- package/lib/typescript/src/components/Circle.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Circle.web.d.ts +3 -0
- package/lib/typescript/src/components/Circle.web.d.ts.map +1 -0
- package/lib/typescript/src/components/GeoJson.d.ts +2 -1
- package/lib/typescript/src/components/GeoJson.d.ts.map +1 -1
- package/lib/typescript/src/components/GroundOverlay.d.ts +10 -0
- package/lib/typescript/src/components/GroundOverlay.d.ts.map +1 -0
- package/lib/typescript/src/components/GroundOverlay.types.d.ts +35 -0
- package/lib/typescript/src/components/GroundOverlay.types.d.ts.map +1 -0
- package/lib/typescript/src/components/GroundOverlay.web.d.ts +3 -0
- package/lib/typescript/src/components/GroundOverlay.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.d.ts +6 -3
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.types.d.ts +18 -6
- package/lib/typescript/src/components/Marker.types.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.web.d.ts +3 -2
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Polygon.web.d.ts +1 -1
- package/lib/typescript/src/components/Polygon.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.web.d.ts +1 -1
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
- package/lib/typescript/src/components/TileOverlay.d.ts +10 -0
- package/lib/typescript/src/components/TileOverlay.d.ts.map +1 -0
- package/lib/typescript/src/components/TileOverlay.types.d.ts +36 -0
- package/lib/typescript/src/components/TileOverlay.types.d.ts.map +1 -0
- package/lib/typescript/src/components/TileOverlay.web.d.ts +3 -0
- package/lib/typescript/src/components/TileOverlay.web.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +7 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/index.web.d.ts +6 -0
- package/lib/typescript/src/components/index.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/fabric/LuggCircleViewNativeComponent.d.ts +18 -0
- package/lib/typescript/src/fabric/LuggCircleViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggGroundOverlayViewNativeComponent.d.ts +21 -0
- package/lib/typescript/src/fabric/LuggGroundOverlayViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts +13 -5
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +8 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggTileOverlayViewNativeComponent.d.ts +21 -0
- package/lib/typescript/src/fabric/LuggTileOverlayViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +7 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +0 -4
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +17 -11
- package/src/MapProvider.web.tsx +5 -3
- package/src/MapView.tsx +19 -1
- package/src/MapView.types.ts +142 -1
- package/src/MapView.web.tsx +379 -340
- package/src/components/Circle.tsx +52 -0
- package/src/components/Circle.types.ts +33 -0
- package/src/components/Circle.web.tsx +95 -0
- package/src/components/GeoJson.tsx +3 -3
- package/src/components/GroundOverlay.tsx +47 -0
- package/src/components/GroundOverlay.types.ts +36 -0
- package/src/components/GroundOverlay.web.tsx +81 -0
- package/src/components/Marker.tsx +32 -6
- package/src/components/Marker.types.ts +19 -6
- package/src/components/Marker.web.tsx +196 -150
- package/src/components/Polygon.web.tsx +93 -89
- package/src/components/Polyline.web.tsx +235 -235
- package/src/components/TileOverlay.tsx +44 -0
- package/src/components/TileOverlay.types.ts +37 -0
- package/src/components/TileOverlay.web.tsx +97 -0
- package/src/components/index.ts +10 -0
- package/src/components/index.web.ts +9 -0
- package/src/fabric/LuggCalloutViewNativeComponent.ts +1 -1
- package/src/fabric/LuggCircleViewNativeComponent.ts +25 -0
- package/src/fabric/LuggGroundOverlayViewNativeComponent.ts +29 -0
- package/src/fabric/LuggMapViewNativeComponent.ts +16 -5
- package/src/fabric/LuggMarkerViewNativeComponent.ts +14 -2
- package/src/fabric/LuggTileOverlayViewNativeComponent.ts +30 -0
- package/src/index.ts +12 -1
- package/src/index.web.ts +15 -0
- package/src/types.ts +0 -5
- package/plugin/build/withMapsAndroid.d.ts +0 -5
- package/plugin/build/withMapsAndroid.js +0 -15
- package/plugin/build/withMapsIOS.d.ts +0 -5
- package/plugin/build/withMapsIOS.js +0 -27
|
@@ -3,12 +3,13 @@ package com.luggmaps
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.graphics.Canvas
|
|
5
5
|
import android.view.View
|
|
6
|
+
import android.view.accessibility.AccessibilityEvent
|
|
6
7
|
import androidx.core.graphics.createBitmap
|
|
7
8
|
import androidx.core.view.isNotEmpty
|
|
8
9
|
import com.facebook.react.views.view.ReactViewGroup
|
|
9
|
-
import com.google.android.gms.maps.model.AdvancedMarker
|
|
10
10
|
import com.google.android.gms.maps.model.BitmapDescriptor
|
|
11
11
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory
|
|
12
|
+
import com.google.android.gms.maps.model.Marker
|
|
12
13
|
import com.luggmaps.events.MarkerDragEvent
|
|
13
14
|
import com.luggmaps.events.MarkerPressEvent
|
|
14
15
|
import com.luggmaps.extensions.dispatchEvent
|
|
@@ -16,6 +17,8 @@ import com.luggmaps.extensions.dispatchEvent
|
|
|
16
17
|
interface LuggMarkerViewDelegate {
|
|
17
18
|
fun markerViewDidUpdate(markerView: LuggMarkerView)
|
|
18
19
|
fun markerViewDidLayout(markerView: LuggMarkerView)
|
|
20
|
+
fun showCalloutForMarkerView(markerView: LuggMarkerView)
|
|
21
|
+
fun hideCalloutForMarkerView(markerView: LuggMarkerView)
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
@@ -35,7 +38,7 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
35
38
|
private set
|
|
36
39
|
|
|
37
40
|
var delegate: LuggMarkerViewDelegate? = null
|
|
38
|
-
var marker:
|
|
41
|
+
var marker: Marker? = null
|
|
39
42
|
|
|
40
43
|
var anchorX: Float = 0.5f
|
|
41
44
|
private set
|
|
@@ -57,6 +60,9 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
57
60
|
var rasterize: Boolean = true
|
|
58
61
|
private set
|
|
59
62
|
|
|
63
|
+
var centerOnPress: Boolean = true
|
|
64
|
+
private set
|
|
65
|
+
|
|
60
66
|
var draggable: Boolean = false
|
|
61
67
|
private set
|
|
62
68
|
|
|
@@ -75,6 +81,12 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
75
81
|
var calloutView: LuggCalloutView? = null
|
|
76
82
|
private set
|
|
77
83
|
|
|
84
|
+
val scaledContentHeight: Float
|
|
85
|
+
get() {
|
|
86
|
+
val (_, height) = measureContentBounds()
|
|
87
|
+
return height * scale
|
|
88
|
+
}
|
|
89
|
+
|
|
78
90
|
private fun measureContentBounds(): Pair<Int, Int> {
|
|
79
91
|
var maxWidth = 0
|
|
80
92
|
var maxHeight = 0
|
|
@@ -207,6 +219,10 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
207
219
|
return null
|
|
208
220
|
}
|
|
209
221
|
|
|
222
|
+
// no-op: avoid accessibility traversal of detached marker children
|
|
223
|
+
override fun addChildrenForAccessibility(outChildren: ArrayList<View>) {}
|
|
224
|
+
override fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent): Boolean = false
|
|
225
|
+
|
|
210
226
|
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
211
227
|
super.onSizeChanged(w, h, oldw, oldh)
|
|
212
228
|
didLayout = false
|
|
@@ -266,6 +282,10 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
266
282
|
this.rasterize = rasterize
|
|
267
283
|
}
|
|
268
284
|
|
|
285
|
+
fun setCenterOnPress(centerOnPress: Boolean) {
|
|
286
|
+
this.centerOnPress = centerOnPress
|
|
287
|
+
}
|
|
288
|
+
|
|
269
289
|
fun setDraggable(draggable: Boolean) {
|
|
270
290
|
this.draggable = draggable
|
|
271
291
|
}
|
|
@@ -286,6 +306,14 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
286
306
|
dispatchEvent(MarkerDragEvent(this, MarkerDragEvent.DRAG_END, latitude, longitude, x, y))
|
|
287
307
|
}
|
|
288
308
|
|
|
309
|
+
fun showCallout() {
|
|
310
|
+
delegate?.showCalloutForMarkerView(this)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
fun hideCallout() {
|
|
314
|
+
delegate?.hideCalloutForMarkerView(this)
|
|
315
|
+
}
|
|
316
|
+
|
|
289
317
|
fun setName(name: String?) {
|
|
290
318
|
this.name = name
|
|
291
319
|
}
|
|
@@ -92,11 +92,24 @@ class LuggMarkerViewManager :
|
|
|
92
92
|
view.setRasterize(value)
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
@ReactProp(name = "centerOnPress", defaultBoolean = true)
|
|
96
|
+
override fun setCenterOnPress(view: LuggMarkerView, value: Boolean) {
|
|
97
|
+
view.setCenterOnPress(value)
|
|
98
|
+
}
|
|
99
|
+
|
|
95
100
|
@ReactProp(name = "draggable", defaultBoolean = false)
|
|
96
101
|
override fun setDraggable(view: LuggMarkerView, value: Boolean) {
|
|
97
102
|
view.setDraggable(value)
|
|
98
103
|
}
|
|
99
104
|
|
|
105
|
+
override fun showCallout(view: LuggMarkerView) {
|
|
106
|
+
view.showCallout()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
override fun hideCallout(view: LuggMarkerView) {
|
|
110
|
+
view.hideCallout()
|
|
111
|
+
}
|
|
112
|
+
|
|
100
113
|
companion object {
|
|
101
114
|
const val NAME = "LuggMarkerView"
|
|
102
115
|
}
|
|
@@ -12,6 +12,9 @@ class LuggPackage : ReactPackage {
|
|
|
12
12
|
LuggCalloutViewManager(),
|
|
13
13
|
LuggMapWrapperViewManager(),
|
|
14
14
|
LuggPolylineViewManager(),
|
|
15
|
-
LuggPolygonViewManager()
|
|
15
|
+
LuggPolygonViewManager(),
|
|
16
|
+
LuggCircleViewManager(),
|
|
17
|
+
LuggGroundOverlayViewManager(),
|
|
18
|
+
LuggTileOverlayViewManager()
|
|
16
19
|
)
|
|
17
20
|
}
|
|
@@ -5,11 +5,10 @@ import android.graphics.Color
|
|
|
5
5
|
import com.facebook.react.views.view.ReactViewGroup
|
|
6
6
|
import com.google.android.gms.maps.model.LatLng
|
|
7
7
|
import com.google.android.gms.maps.model.Polyline
|
|
8
|
-
import com.google.android.gms.maps.model.StrokeStyle
|
|
9
|
-
import com.google.android.gms.maps.model.StyleSpan
|
|
10
8
|
|
|
11
9
|
interface LuggPolylineViewDelegate {
|
|
12
10
|
fun polylineViewDidUpdate(polylineView: LuggPolylineView)
|
|
11
|
+
fun polylineViewDidDrop(polylineView: LuggPolylineView)
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
data class AnimatedOptions(val duration: Long = 2150L, val easing: String = "linear", val trailLength: Float = 1f, val delay: Long = 0L)
|
|
@@ -33,9 +32,6 @@ class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
33
32
|
var zIndex: Float = 0f
|
|
34
33
|
private set
|
|
35
34
|
|
|
36
|
-
var cachedSpans: List<StyleSpan>? = null
|
|
37
|
-
private set
|
|
38
|
-
|
|
39
35
|
var delegate: LuggPolylineViewDelegate? = null
|
|
40
36
|
var polyline: Polyline? = null
|
|
41
37
|
|
|
@@ -48,11 +44,7 @@ class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
fun setStrokeColors(colors: List<Int>) {
|
|
51
|
-
|
|
52
|
-
if (newColors != strokeColors) {
|
|
53
|
-
strokeColors = newColors
|
|
54
|
-
cachedSpans = null
|
|
55
|
-
}
|
|
47
|
+
strokeColors = colors.ifEmpty { listOf(Color.BLACK) }
|
|
56
48
|
}
|
|
57
49
|
|
|
58
50
|
fun setStrokeWidth(width: Float) {
|
|
@@ -71,25 +63,13 @@ class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
71
63
|
zIndex = value
|
|
72
64
|
}
|
|
73
65
|
|
|
74
|
-
fun getOrCreateSpans(): List<StyleSpan> {
|
|
75
|
-
cachedSpans?.let { return it }
|
|
76
|
-
|
|
77
|
-
val segmentCount = coordinates.size - 1
|
|
78
|
-
val spans = (0 until segmentCount).map { i ->
|
|
79
|
-
val color = strokeColors[i % strokeColors.size]
|
|
80
|
-
StyleSpan(StrokeStyle.colorBuilder(color).build())
|
|
81
|
-
}
|
|
82
|
-
cachedSpans = spans
|
|
83
|
-
return spans
|
|
84
|
-
}
|
|
85
|
-
|
|
86
66
|
fun onAfterUpdateTransaction() {
|
|
87
67
|
delegate?.polylineViewDidUpdate(this)
|
|
88
68
|
}
|
|
89
69
|
|
|
90
70
|
fun onDropViewInstance() {
|
|
71
|
+
delegate?.polylineViewDidDrop(this)
|
|
91
72
|
delegate = null
|
|
92
|
-
polyline?.remove()
|
|
93
73
|
polyline = null
|
|
94
74
|
}
|
|
95
75
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
package com.luggmaps
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
5
|
+
import com.google.android.gms.maps.model.TileOverlay
|
|
6
|
+
import com.luggmaps.events.TileOverlayPressEvent
|
|
7
|
+
import com.luggmaps.extensions.dispatchEvent
|
|
8
|
+
|
|
9
|
+
interface LuggTileOverlayViewDelegate {
|
|
10
|
+
fun tileOverlayViewDidUpdate(tileOverlayView: LuggTileOverlayView)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class LuggTileOverlayView(context: Context) : ReactViewGroup(context) {
|
|
14
|
+
var urlTemplate: String = ""
|
|
15
|
+
private set
|
|
16
|
+
|
|
17
|
+
var tileSize: Int = 256
|
|
18
|
+
private set
|
|
19
|
+
|
|
20
|
+
var overlayOpacity: Float = 1f
|
|
21
|
+
private set
|
|
22
|
+
|
|
23
|
+
var hasBounds: Boolean = false
|
|
24
|
+
private set
|
|
25
|
+
var boundsSwLat: Double = 0.0
|
|
26
|
+
private set
|
|
27
|
+
var boundsSwLng: Double = 0.0
|
|
28
|
+
private set
|
|
29
|
+
var boundsNeLat: Double = 0.0
|
|
30
|
+
private set
|
|
31
|
+
var boundsNeLng: Double = 0.0
|
|
32
|
+
private set
|
|
33
|
+
|
|
34
|
+
var zIndex: Float = 0f
|
|
35
|
+
private set
|
|
36
|
+
|
|
37
|
+
var tappable: Boolean = false
|
|
38
|
+
private set
|
|
39
|
+
|
|
40
|
+
var delegate: LuggTileOverlayViewDelegate? = null
|
|
41
|
+
var tileOverlay: TileOverlay? = null
|
|
42
|
+
|
|
43
|
+
init {
|
|
44
|
+
visibility = GONE
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
fun setUrlTemplate(value: String) {
|
|
48
|
+
urlTemplate = value
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
fun setTileSize(value: Int) {
|
|
52
|
+
tileSize = value
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
fun setOverlayOpacity(value: Float) {
|
|
56
|
+
overlayOpacity = value
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
fun setZIndex(value: Float) {
|
|
60
|
+
zIndex = value
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fun setBounds(swLat: Double, swLng: Double, neLat: Double, neLng: Double) {
|
|
64
|
+
hasBounds = true
|
|
65
|
+
boundsSwLat = swLat
|
|
66
|
+
boundsSwLng = swLng
|
|
67
|
+
boundsNeLat = neLat
|
|
68
|
+
boundsNeLng = neLng
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fun clearBounds() {
|
|
72
|
+
hasBounds = false
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
fun setTappable(value: Boolean) {
|
|
76
|
+
tappable = value
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
fun emitPressEvent() {
|
|
80
|
+
dispatchEvent(TileOverlayPressEvent(this))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fun onAfterUpdateTransaction() {
|
|
84
|
+
delegate?.tileOverlayViewDidUpdate(this)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
fun onDropViewInstance() {
|
|
88
|
+
delegate = null
|
|
89
|
+
tileOverlay?.remove()
|
|
90
|
+
tileOverlay = null
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
package com.luggmaps
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
7
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
8
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
|
+
import com.facebook.react.viewmanagers.LuggTileOverlayViewManagerDelegate
|
|
10
|
+
import com.facebook.react.viewmanagers.LuggTileOverlayViewManagerInterface
|
|
11
|
+
|
|
12
|
+
@ReactModule(name = LuggTileOverlayViewManager.NAME)
|
|
13
|
+
class LuggTileOverlayViewManager :
|
|
14
|
+
ViewGroupManager<LuggTileOverlayView>(),
|
|
15
|
+
LuggTileOverlayViewManagerInterface<LuggTileOverlayView> {
|
|
16
|
+
private val delegate: ViewManagerDelegate<LuggTileOverlayView> = LuggTileOverlayViewManagerDelegate(this)
|
|
17
|
+
|
|
18
|
+
override fun getDelegate(): ViewManagerDelegate<LuggTileOverlayView> = delegate
|
|
19
|
+
override fun getName(): String = NAME
|
|
20
|
+
override fun createViewInstance(context: ThemedReactContext): LuggTileOverlayView = LuggTileOverlayView(context)
|
|
21
|
+
|
|
22
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> =
|
|
23
|
+
mapOf("topTileOverlayPress" to mapOf("registrationName" to "onTileOverlayPress"))
|
|
24
|
+
|
|
25
|
+
override fun onDropViewInstance(view: LuggTileOverlayView) {
|
|
26
|
+
super.onDropViewInstance(view)
|
|
27
|
+
view.onDropViewInstance()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun onAfterUpdateTransaction(view: LuggTileOverlayView) {
|
|
31
|
+
super.onAfterUpdateTransaction(view)
|
|
32
|
+
view.onAfterUpdateTransaction()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@ReactProp(name = "urlTemplate")
|
|
36
|
+
override fun setUrlTemplate(view: LuggTileOverlayView, value: String?) {
|
|
37
|
+
view.setUrlTemplate(value ?: "")
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@ReactProp(name = "tileSize", defaultInt = 256)
|
|
41
|
+
override fun setTileSize(view: LuggTileOverlayView, value: Int) {
|
|
42
|
+
view.setTileSize(value)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@ReactProp(name = "opacity", defaultDouble = 1.0)
|
|
46
|
+
override fun setOpacity(view: LuggTileOverlayView, value: Double) {
|
|
47
|
+
view.setOverlayOpacity(value.toFloat())
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@ReactProp(name = "bounds")
|
|
51
|
+
override fun setBounds(view: LuggTileOverlayView, value: ReadableMap?) {
|
|
52
|
+
if (value == null) {
|
|
53
|
+
view.clearBounds()
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
val ne = value.getMap("northeast")
|
|
57
|
+
val sw = value.getMap("southwest")
|
|
58
|
+
view.setBounds(
|
|
59
|
+
sw?.getDouble("latitude") ?: 0.0,
|
|
60
|
+
sw?.getDouble("longitude") ?: 0.0,
|
|
61
|
+
ne?.getDouble("latitude") ?: 0.0,
|
|
62
|
+
ne?.getDouble("longitude") ?: 0.0
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@ReactProp(name = "tappable")
|
|
67
|
+
override fun setTappable(view: LuggTileOverlayView, value: Boolean) {
|
|
68
|
+
view.setTappable(value)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@ReactProp(name = "zIndex", defaultFloat = 0f)
|
|
72
|
+
override fun setZIndex(view: LuggTileOverlayView, value: Float) {
|
|
73
|
+
super.setZIndex(view, value)
|
|
74
|
+
view.setZIndex(value)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
companion object {
|
|
78
|
+
const val NAME = "LuggTileOverlayView"
|
|
79
|
+
}
|
|
80
|
+
}
|