@lugg/maps 1.0.0-beta.0 → 1.0.0-beta.10
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 +4 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/luggmaps/LuggCalloutView.kt +79 -0
- package/android/src/main/java/com/luggmaps/LuggCalloutViewManager.kt +39 -0
- 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 +49 -0
- package/android/src/main/java/com/luggmaps/LuggMapViewManager.kt +31 -0
- package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +0 -11
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +99 -51
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +13 -0
- package/android/src/main/java/com/luggmaps/LuggPackage.kt +11 -1
- package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +1 -22
- 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 +628 -18
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +14 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +12 -7
- 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 +23 -0
- package/ios/LuggCalloutView.mm +155 -0
- 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 +84 -2
- package/ios/LuggMarkerView.h +5 -0
- package/ios/LuggMarkerView.mm +40 -2
- package/ios/LuggTileOverlayView.h +31 -0
- package/ios/LuggTileOverlayView.mm +130 -0
- package/ios/core/AppleMapProvider.mm +838 -34
- package/ios/core/GMSPolylineAnimator.m +6 -3
- package/ios/core/GoogleMapProvider.mm +506 -19
- package/ios/core/LuggAnnotationView.h +12 -0
- package/ios/core/LuggAnnotationView.mm +55 -0
- package/ios/core/MapProviderDelegate.h +20 -1
- package/ios/events/CirclePressEvent.h +20 -0
- package/ios/events/GroundOverlayPressEvent.h +20 -0
- package/ios/events/TileOverlayPressEvent.h +20 -0
- package/lib/module/MapProvider.web.js +7 -2
- package/lib/module/MapProvider.web.js.map +1 -1
- package/lib/module/MapView.js +12 -1
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +36 -20
- 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 +41 -6
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.web.js +103 -26
- 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 +20 -0
- package/lib/module/fabric/LuggCircleViewNativeComponent.ts +25 -0
- package/lib/module/fabric/LuggGroundOverlayViewNativeComponent.ts +29 -0
- package/lib/module/fabric/LuggMapViewNativeComponent.ts +13 -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 +9 -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 +36 -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/GeoJson.types.d.ts +11 -1
- package/lib/typescript/src/components/GeoJson.types.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 +40 -2
- 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 +7 -1
- package/lib/typescript/src/components/index.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts +13 -0
- package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts.map +1 -0
- 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 +10 -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 +10 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +9 -3
- 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 +6 -2
- package/src/MapProvider.web.tsx +15 -3
- package/src/MapView.tsx +12 -1
- package/src/MapView.types.ts +118 -1
- package/src/MapView.web.tsx +379 -322
- 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/GeoJson.types.ts +12 -1
- 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 +59 -5
- package/src/components/Marker.types.ts +42 -2
- package/src/components/Marker.web.tsx +235 -99
- 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 +11 -0
- package/src/components/index.web.ts +10 -1
- package/src/fabric/LuggCalloutViewNativeComponent.ts +20 -0
- package/src/fabric/LuggCircleViewNativeComponent.ts +25 -0
- package/src/fabric/LuggGroundOverlayViewNativeComponent.ts +29 -0
- package/src/fabric/LuggMapViewNativeComponent.ts +13 -5
- package/src/fabric/LuggMarkerViewNativeComponent.ts +14 -2
- package/src/fabric/LuggTileOverlayViewNativeComponent.ts +30 -0
- package/src/index.ts +14 -1
- package/src/index.web.ts +17 -1
- package/src/types.ts +0 -5
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
package com.luggmaps
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
-
import android.graphics.Bitmap
|
|
5
4
|
import android.graphics.Canvas
|
|
6
5
|
import android.view.View
|
|
7
|
-
import android.view.ViewGroup
|
|
8
6
|
import androidx.core.graphics.createBitmap
|
|
9
7
|
import androidx.core.view.isNotEmpty
|
|
10
8
|
import com.facebook.react.views.view.ReactViewGroup
|
|
@@ -18,6 +16,8 @@ import com.luggmaps.extensions.dispatchEvent
|
|
|
18
16
|
interface LuggMarkerViewDelegate {
|
|
19
17
|
fun markerViewDidUpdate(markerView: LuggMarkerView)
|
|
20
18
|
fun markerViewDidLayout(markerView: LuggMarkerView)
|
|
19
|
+
fun showCalloutForMarkerView(markerView: LuggMarkerView)
|
|
20
|
+
fun hideCalloutForMarkerView(markerView: LuggMarkerView)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
@@ -59,6 +59,9 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
59
59
|
var rasterize: Boolean = true
|
|
60
60
|
private set
|
|
61
61
|
|
|
62
|
+
var centerOnPress: Boolean = true
|
|
63
|
+
private set
|
|
64
|
+
|
|
62
65
|
var draggable: Boolean = false
|
|
63
66
|
private set
|
|
64
67
|
|
|
@@ -68,15 +71,26 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
68
71
|
private set
|
|
69
72
|
|
|
70
73
|
val hasCustomView: Boolean
|
|
71
|
-
get() =
|
|
74
|
+
get() = contentView.isNotEmpty()
|
|
75
|
+
|
|
76
|
+
val contentView: ReactViewGroup = ReactViewGroup(context)
|
|
72
77
|
|
|
73
|
-
|
|
78
|
+
var onUpdate: (() -> Unit)? = null
|
|
79
|
+
|
|
80
|
+
var calloutView: LuggCalloutView? = null
|
|
81
|
+
private set
|
|
74
82
|
|
|
75
|
-
|
|
83
|
+
val scaledContentHeight: Float
|
|
84
|
+
get() {
|
|
85
|
+
val (_, height) = measureContentBounds()
|
|
86
|
+
return height * scale
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private fun measureContentBounds(): Pair<Int, Int> {
|
|
76
90
|
var maxWidth = 0
|
|
77
91
|
var maxHeight = 0
|
|
78
|
-
for (i in 0 until
|
|
79
|
-
val child =
|
|
92
|
+
for (i in 0 until contentView.childCount) {
|
|
93
|
+
val child = contentView.getChildAt(i)
|
|
80
94
|
val childRight = child.left + child.width
|
|
81
95
|
val childBottom = child.top + child.height
|
|
82
96
|
if (childRight > maxWidth) maxWidth = childRight
|
|
@@ -85,8 +99,8 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
85
99
|
return Pair(maxWidth, maxHeight)
|
|
86
100
|
}
|
|
87
101
|
|
|
88
|
-
private fun
|
|
89
|
-
val (width, height) =
|
|
102
|
+
private fun createContentBitmap(): BitmapDescriptor? {
|
|
103
|
+
val (width, height) = measureContentBounds()
|
|
90
104
|
if (width <= 0 || height <= 0) return null
|
|
91
105
|
|
|
92
106
|
val scaledWidth = (width * scale).toInt()
|
|
@@ -95,41 +109,31 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
95
109
|
val bitmap = createBitmap(scaledWidth, scaledHeight)
|
|
96
110
|
val canvas = Canvas(bitmap)
|
|
97
111
|
canvas.scale(scale, scale)
|
|
98
|
-
|
|
112
|
+
contentView.draw(canvas)
|
|
99
113
|
return BitmapDescriptorFactory.fromBitmap(bitmap)
|
|
100
114
|
}
|
|
101
115
|
|
|
102
|
-
|
|
103
|
-
val (width, height) =
|
|
116
|
+
fun layoutContentView() {
|
|
117
|
+
val (width, height) = measureContentBounds()
|
|
104
118
|
val scaledWidth = (width * scale).toInt()
|
|
105
119
|
val scaledHeight = (height * scale).toInt()
|
|
106
120
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
iconView.pivotY = 0f
|
|
112
|
-
|
|
113
|
-
return object : ReactViewGroup(context) {
|
|
114
|
-
init {
|
|
115
|
-
addView(iconView)
|
|
116
|
-
}
|
|
121
|
+
contentView.scaleX = scale
|
|
122
|
+
contentView.scaleY = scale
|
|
123
|
+
contentView.pivotX = 0f
|
|
124
|
+
contentView.pivotY = 0f
|
|
117
125
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
126
|
+
contentView.measure(
|
|
127
|
+
View.MeasureSpec.makeMeasureSpec(scaledWidth, View.MeasureSpec.EXACTLY),
|
|
128
|
+
View.MeasureSpec.makeMeasureSpec(scaledHeight, View.MeasureSpec.EXACTLY)
|
|
129
|
+
)
|
|
130
|
+
contentView.layout(0, 0, scaledWidth, scaledHeight)
|
|
122
131
|
}
|
|
123
132
|
|
|
124
133
|
fun applyIconToMarker() {
|
|
125
134
|
val m = marker ?: return
|
|
126
135
|
if (!hasCustomView) return
|
|
127
|
-
|
|
128
|
-
if (rasterize) {
|
|
129
|
-
createIconBitmap()?.let { m.setIcon(it) }
|
|
130
|
-
} else {
|
|
131
|
-
m.iconView = createIconViewWrapper()
|
|
132
|
-
}
|
|
136
|
+
createContentBitmap()?.let { m.setIcon(it) }
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
fun applyScaleToMarker() {
|
|
@@ -139,9 +143,10 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
139
143
|
scaleUpdateRunnable?.let { removeCallbacks(it) }
|
|
140
144
|
scaleUpdateRunnable = Runnable {
|
|
141
145
|
if (rasterize) {
|
|
142
|
-
|
|
146
|
+
createContentBitmap()?.let { m.setIcon(it) }
|
|
143
147
|
} else {
|
|
144
|
-
|
|
148
|
+
layoutContentView()
|
|
149
|
+
onUpdate?.invoke()
|
|
145
150
|
}
|
|
146
151
|
}
|
|
147
152
|
post(scaleUpdateRunnable)
|
|
@@ -149,18 +154,15 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
149
154
|
|
|
150
155
|
fun updateIcon(onAddMarker: () -> Unit) {
|
|
151
156
|
if (!hasCustomView) return
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
post {
|
|
158
|
+
if (marker == null) {
|
|
159
|
+
onAddMarker()
|
|
160
|
+
} else if (rasterize) {
|
|
161
|
+
applyIconToMarker()
|
|
162
|
+
} else {
|
|
163
|
+
layoutContentView()
|
|
164
|
+
onUpdate?.invoke()
|
|
159
165
|
}
|
|
160
|
-
} else {
|
|
161
|
-
marker?.remove()
|
|
162
|
-
marker = null
|
|
163
|
-
post { onAddMarker() }
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
168
|
|
|
@@ -169,23 +171,55 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
169
171
|
}
|
|
170
172
|
|
|
171
173
|
override fun addView(child: View, index: Int) {
|
|
172
|
-
|
|
174
|
+
if (child is LuggCalloutView) {
|
|
175
|
+
calloutView = child
|
|
176
|
+
} else {
|
|
177
|
+
contentView.addView(child, index)
|
|
178
|
+
}
|
|
173
179
|
didLayout = false
|
|
174
180
|
}
|
|
175
181
|
|
|
176
182
|
override fun removeView(child: View) {
|
|
177
|
-
|
|
183
|
+
if (child is LuggCalloutView) {
|
|
184
|
+
calloutView = null
|
|
185
|
+
} else {
|
|
186
|
+
contentView.removeView(child)
|
|
187
|
+
}
|
|
178
188
|
didLayout = false
|
|
179
189
|
}
|
|
180
190
|
|
|
181
191
|
override fun removeViewAt(index: Int) {
|
|
182
|
-
|
|
192
|
+
val child = getChildAt(index)
|
|
193
|
+
if (child is LuggCalloutView) {
|
|
194
|
+
calloutView = null
|
|
195
|
+
} else {
|
|
196
|
+
contentView.removeViewAt(index)
|
|
197
|
+
}
|
|
183
198
|
didLayout = false
|
|
184
199
|
}
|
|
185
200
|
|
|
186
|
-
override fun
|
|
201
|
+
override fun removeViews(start: Int, count: Int) {
|
|
202
|
+
for (i in (start until start + count).reversed()) {
|
|
203
|
+
val child = getChildAt(i)
|
|
204
|
+
if (child is LuggCalloutView) {
|
|
205
|
+
calloutView = null
|
|
206
|
+
} else if (i < contentView.childCount) {
|
|
207
|
+
contentView.removeViewAt(i)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
didLayout = false
|
|
211
|
+
}
|
|
187
212
|
|
|
188
|
-
override fun
|
|
213
|
+
override fun getChildCount(): Int = contentView.childCount + if (calloutView != null) 1 else 0
|
|
214
|
+
|
|
215
|
+
override fun getChildAt(index: Int): View? {
|
|
216
|
+
if (index < contentView.childCount) return contentView.getChildAt(index)
|
|
217
|
+
if (index == contentView.childCount && calloutView != null) return calloutView
|
|
218
|
+
return null
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// no-op: avoid accessibility traversal of detached marker children
|
|
222
|
+
override fun addChildrenForAccessibility(outChildren: ArrayList<View>) {}
|
|
189
223
|
|
|
190
224
|
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
191
225
|
super.onSizeChanged(w, h, oldw, oldh)
|
|
@@ -246,6 +280,10 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
246
280
|
this.rasterize = rasterize
|
|
247
281
|
}
|
|
248
282
|
|
|
283
|
+
fun setCenterOnPress(centerOnPress: Boolean) {
|
|
284
|
+
this.centerOnPress = centerOnPress
|
|
285
|
+
}
|
|
286
|
+
|
|
249
287
|
fun setDraggable(draggable: Boolean) {
|
|
250
288
|
this.draggable = draggable
|
|
251
289
|
}
|
|
@@ -266,6 +304,14 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
266
304
|
dispatchEvent(MarkerDragEvent(this, MarkerDragEvent.DRAG_END, latitude, longitude, x, y))
|
|
267
305
|
}
|
|
268
306
|
|
|
307
|
+
fun showCallout() {
|
|
308
|
+
delegate?.showCalloutForMarkerView(this)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
fun hideCallout() {
|
|
312
|
+
delegate?.hideCalloutForMarkerView(this)
|
|
313
|
+
}
|
|
314
|
+
|
|
269
315
|
fun setName(name: String?) {
|
|
270
316
|
this.name = name
|
|
271
317
|
}
|
|
@@ -277,8 +323,10 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
277
323
|
fun onDropViewInstance() {
|
|
278
324
|
scaleUpdateRunnable?.let { removeCallbacks(it) }
|
|
279
325
|
scaleUpdateRunnable = null
|
|
326
|
+
onUpdate = null
|
|
280
327
|
didLayout = false
|
|
328
|
+
calloutView = null
|
|
281
329
|
delegate = null
|
|
282
|
-
|
|
330
|
+
contentView.removeAllViews()
|
|
283
331
|
}
|
|
284
332
|
}
|
|
@@ -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
|
}
|
|
@@ -6,5 +6,15 @@ import com.facebook.react.uimanager.ViewManager
|
|
|
6
6
|
|
|
7
7
|
class LuggPackage : ReactPackage {
|
|
8
8
|
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
|
|
9
|
-
listOf(
|
|
9
|
+
listOf(
|
|
10
|
+
LuggMapViewManager(),
|
|
11
|
+
LuggMarkerViewManager(),
|
|
12
|
+
LuggCalloutViewManager(),
|
|
13
|
+
LuggMapWrapperViewManager(),
|
|
14
|
+
LuggPolylineViewManager(),
|
|
15
|
+
LuggPolygonViewManager(),
|
|
16
|
+
LuggCircleViewManager(),
|
|
17
|
+
LuggGroundOverlayViewManager(),
|
|
18
|
+
LuggTileOverlayViewManager()
|
|
19
|
+
)
|
|
10
20
|
}
|
|
@@ -5,8 +5,6 @@ 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)
|
|
@@ -33,9 +31,6 @@ class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
33
31
|
var zIndex: Float = 0f
|
|
34
32
|
private set
|
|
35
33
|
|
|
36
|
-
var cachedSpans: List<StyleSpan>? = null
|
|
37
|
-
private set
|
|
38
|
-
|
|
39
34
|
var delegate: LuggPolylineViewDelegate? = null
|
|
40
35
|
var polyline: Polyline? = null
|
|
41
36
|
|
|
@@ -48,11 +43,7 @@ class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
48
43
|
}
|
|
49
44
|
|
|
50
45
|
fun setStrokeColors(colors: List<Int>) {
|
|
51
|
-
|
|
52
|
-
if (newColors != strokeColors) {
|
|
53
|
-
strokeColors = newColors
|
|
54
|
-
cachedSpans = null
|
|
55
|
-
}
|
|
46
|
+
strokeColors = colors.ifEmpty { listOf(Color.BLACK) }
|
|
56
47
|
}
|
|
57
48
|
|
|
58
49
|
fun setStrokeWidth(width: Float) {
|
|
@@ -71,18 +62,6 @@ class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
71
62
|
zIndex = value
|
|
72
63
|
}
|
|
73
64
|
|
|
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
65
|
fun onAfterUpdateTransaction() {
|
|
87
66
|
delegate?.polylineViewDidUpdate(this)
|
|
88
67
|
}
|
|
@@ -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
|
+
}
|