@lugg/maps 0.2.0-alpha.0 → 0.2.0-alpha.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/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapView.kt → LuggGoogleMapView.kt} +81 -28
- package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapViewManager.kt → LuggGoogleMapViewManager.kt} +57 -38
- package/android/src/main/java/com/luggmaps/{LuggMapsWrapperView.kt → LuggMapWrapperView.kt} +1 -1
- package/android/src/main/java/com/luggmaps/LuggMapWrapperViewManager.kt +25 -0
- package/android/src/main/java/com/luggmaps/{LuggMapsMarkerView.kt → LuggMarkerView.kt} +6 -6
- package/android/src/main/java/com/luggmaps/{LuggMapsMarkerViewManager.kt → LuggMarkerViewManager.kt} +17 -17
- package/android/src/main/java/com/luggmaps/{LuggMapsPackage.kt → LuggPackage.kt} +2 -2
- package/android/src/main/java/com/luggmaps/{LuggMapsPolylineView.kt → LuggPolylineView.kt} +4 -4
- package/android/src/main/java/com/luggmaps/{LuggMapsPolylineViewManager.kt → LuggPolylineViewManager.kt} +16 -16
- package/android/src/main/java/com/luggmaps/events/CameraIdleEvent.kt +10 -2
- package/android/src/main/java/com/luggmaps/events/CameraMoveEvent.kt +6 -5
- package/android/src/main/java/com/luggmaps/events/ReadyEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/extensions/ViewExtensions.kt +14 -0
- package/ios/{LuggMapsAppleMapView.h → LuggAppleMapView.h} +2 -2
- package/ios/{LuggMapsAppleMapView.mm → LuggAppleMapView.mm} +95 -66
- package/ios/{LuggMapsGoogleMapView.h → LuggGoogleMapView.h} +1 -1
- package/ios/{LuggMapsGoogleMapView.mm → LuggGoogleMapView.mm} +64 -58
- package/ios/{LuggMapsWrapperView.h → LuggMapWrapperView.h} +1 -1
- package/ios/{LuggMapsWrapperView.mm → LuggMapWrapperView.mm} +7 -7
- package/ios/{LuggMapsMarkerView.h → LuggMarkerView.h} +6 -6
- package/ios/{LuggMapsMarkerView.mm → LuggMarkerView.mm} +8 -8
- package/ios/{LuggMapsPolylineView.h → LuggPolylineView.h} +5 -5
- package/ios/{LuggMapsPolylineView.mm → LuggPolylineView.mm} +8 -8
- package/ios/events/CameraIdleEvent.h +6 -1
- package/ios/events/CameraMoveEvent.h +6 -3
- package/ios/events/ReadyEvent.h +20 -0
- package/lib/module/MapView.js +13 -5
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/{Marker.js → components/Marker.js} +2 -2
- package/lib/module/components/Marker.js.map +1 -0
- package/lib/module/{Polyline.js → components/Polyline.js} +2 -2
- package/lib/module/components/Polyline.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -0
- package/{src/fabric/LuggMapsAppleMapViewNativeComponent.ts → lib/module/fabric/LuggAppleMapViewNativeComponent.ts} +9 -2
- package/lib/module/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +9 -2
- package/{src/fabric/LuggMapsWrapperViewNativeComponent.ts → lib/module/fabric/LuggMapWrapperViewNativeComponent.ts} +1 -1
- package/lib/module/fabric/{LuggMapsMarkerViewNativeComponent.ts → LuggMarkerViewNativeComponent.ts} +1 -1
- package/{src/fabric/LuggMapsPolylineViewNativeComponent.ts → lib/module/fabric/LuggPolylineViewNativeComponent.ts} +1 -1
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/plugin/src/withLuggMapsAndroid.d.ts +6 -0
- package/lib/typescript/plugin/src/withLuggMapsAndroid.d.ts.map +1 -0
- package/lib/typescript/plugin/src/withLuggMapsIOS.d.ts +6 -0
- package/lib/typescript/plugin/src/withLuggMapsIOS.d.ts.map +1 -0
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +23 -12
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/{Marker.types.d.ts → components/Marker.d.ts} +6 -5
- package/lib/typescript/src/components/Marker.d.ts.map +1 -0
- package/lib/typescript/src/{Polyline.types.d.ts → components/Polyline.d.ts} +6 -5
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +3 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsAppleMapViewNativeComponent.d.ts → LuggAppleMapViewNativeComponent.d.ts} +9 -2
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsGoogleMapViewNativeComponent.d.ts → LuggGoogleMapViewNativeComponent.d.ts} +9 -2
- package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsWrapperViewNativeComponent.d.ts → LuggMapWrapperViewNativeComponent.d.ts} +1 -1
- package/lib/typescript/src/fabric/LuggMapWrapperViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsMarkerViewNativeComponent.d.ts → LuggMarkerViewNativeComponent.d.ts} +1 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsPolylineViewNativeComponent.d.ts → LuggPolylineViewNativeComponent.d.ts} +1 -1
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +6 -6
- package/plugin/build/index.js +4 -4
- package/{lib/typescript/plugin/src/withMapsAndroid.d.ts → plugin/build/withLuggMapsAndroid.d.ts} +0 -1
- package/plugin/build/withLuggMapsAndroid.js +15 -0
- package/{lib/typescript/plugin/src/withMapsIOS.d.ts → plugin/build/withLuggMapsIOS.d.ts} +0 -1
- package/plugin/build/withLuggMapsIOS.js +27 -0
- package/plugin/build/withMapsAndroid.d.ts +1 -1
- package/plugin/build/withMapsIOS.d.ts +1 -1
- package/src/MapView.tsx +16 -8
- package/src/MapView.types.ts +23 -13
- package/src/components/Marker.tsx +59 -0
- package/src/{Polyline.tsx → components/Polyline.tsx} +23 -3
- package/src/components/index.ts +2 -0
- package/{lib/module/fabric/LuggMapsAppleMapViewNativeComponent.ts → src/fabric/LuggAppleMapViewNativeComponent.ts} +9 -2
- package/src/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +9 -2
- package/{lib/module/fabric/LuggMapsWrapperViewNativeComponent.ts → src/fabric/LuggMapWrapperViewNativeComponent.ts} +1 -1
- package/src/fabric/{LuggMapsMarkerViewNativeComponent.ts → LuggMarkerViewNativeComponent.ts} +1 -1
- package/{lib/module/fabric/LuggMapsPolylineViewNativeComponent.ts → src/fabric/LuggPolylineViewNativeComponent.ts} +1 -1
- package/src/index.ts +3 -6
- package/android/src/main/java/com/luggmaps/LuggMapsWrapperViewManager.kt +0 -25
- package/lib/module/Marker.js.map +0 -1
- package/lib/module/Marker.types.js +0 -4
- package/lib/module/Marker.types.js.map +0 -1
- package/lib/module/Polyline.js.map +0 -1
- package/lib/module/Polyline.types.js +0 -4
- package/lib/module/Polyline.types.js.map +0 -1
- package/lib/typescript/plugin/src/withMapsAndroid.d.ts.map +0 -1
- package/lib/typescript/plugin/src/withMapsIOS.d.ts.map +0 -1
- package/lib/typescript/src/Marker.d.ts +0 -6
- package/lib/typescript/src/Marker.d.ts.map +0 -1
- package/lib/typescript/src/Marker.types.d.ts.map +0 -1
- package/lib/typescript/src/Polyline.d.ts +0 -6
- package/lib/typescript/src/Polyline.d.ts.map +0 -1
- package/lib/typescript/src/Polyline.types.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsAppleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsGoogleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsMarkerViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsPolylineViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsWrapperViewNativeComponent.d.ts.map +0 -1
- package/src/Marker.tsx +0 -31
- package/src/Marker.types.ts +0 -32
- package/src/Polyline.types.ts +0 -24
package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapView.kt → LuggGoogleMapView.kt}
RENAMED
|
@@ -20,37 +20,44 @@ import com.google.android.gms.maps.model.LatLng
|
|
|
20
20
|
import com.google.android.gms.maps.model.PolylineOptions
|
|
21
21
|
import com.luggmaps.core.PolylineAnimator
|
|
22
22
|
|
|
23
|
-
interface
|
|
23
|
+
interface LuggGoogleMapViewEventDelegate {
|
|
24
24
|
fun onCameraMove(
|
|
25
|
-
view:
|
|
25
|
+
view: LuggGoogleMapView,
|
|
26
26
|
latitude: Double,
|
|
27
27
|
longitude: Double,
|
|
28
28
|
zoom: Float,
|
|
29
|
-
|
|
29
|
+
gesture: Boolean
|
|
30
30
|
)
|
|
31
|
-
fun onCameraIdle(
|
|
31
|
+
fun onCameraIdle(
|
|
32
|
+
view: LuggGoogleMapView,
|
|
33
|
+
latitude: Double,
|
|
34
|
+
longitude: Double,
|
|
35
|
+
zoom: Float,
|
|
36
|
+
gesture: Boolean
|
|
37
|
+
)
|
|
38
|
+
fun onReady(view: LuggGoogleMapView)
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
@SuppressLint("ViewConstructor")
|
|
35
|
-
class
|
|
42
|
+
class LuggGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
36
43
|
ReactViewGroup(reactContext),
|
|
37
44
|
OnMapReadyCallback,
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
LuggMarkerViewDelegate,
|
|
46
|
+
LuggPolylineViewDelegate,
|
|
40
47
|
GoogleMap.OnCameraMoveStartedListener,
|
|
41
48
|
GoogleMap.OnCameraMoveListener,
|
|
42
49
|
GoogleMap.OnCameraIdleListener {
|
|
43
50
|
|
|
44
|
-
var eventDelegate:
|
|
51
|
+
var eventDelegate: LuggGoogleMapViewEventDelegate? = null
|
|
45
52
|
private var mapView: MapView? = null
|
|
46
|
-
private var mapWrapperView:
|
|
53
|
+
private var mapWrapperView: LuggMapWrapperView? = null
|
|
47
54
|
private var googleMap: GoogleMap? = null
|
|
48
55
|
private var isMapReady = false
|
|
49
56
|
private var isDragging = false
|
|
50
57
|
private var mapId: String = DEMO_MAP_ID
|
|
51
|
-
private val pendingMarkerViews = mutableListOf<
|
|
52
|
-
private val pendingPolylineViews = mutableListOf<
|
|
53
|
-
private val polylineAnimators = mutableMapOf<
|
|
58
|
+
private val pendingMarkerViews = mutableListOf<LuggMarkerView>()
|
|
59
|
+
private val pendingPolylineViews = mutableListOf<LuggPolylineView>()
|
|
60
|
+
private val polylineAnimators = mutableMapOf<LuggPolylineView, PolylineAnimator>()
|
|
54
61
|
|
|
55
62
|
// Initial camera settings
|
|
56
63
|
private var initialLatitude: Double = 37.78
|
|
@@ -62,6 +69,11 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
62
69
|
private var scrollEnabled: Boolean = true
|
|
63
70
|
private var rotateEnabled: Boolean = true
|
|
64
71
|
private var pitchEnabled: Boolean = true
|
|
72
|
+
private var userLocationEnabled: Boolean = false
|
|
73
|
+
|
|
74
|
+
// Zoom limits
|
|
75
|
+
private var minZoom: Float? = null
|
|
76
|
+
private var maxZoom: Float? = null
|
|
65
77
|
|
|
66
78
|
// Padding
|
|
67
79
|
private var paddingTop: Int = 0
|
|
@@ -74,14 +86,14 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
74
86
|
override fun addView(child: View?, index: Int) {
|
|
75
87
|
super.addView(child, index)
|
|
76
88
|
when (child) {
|
|
77
|
-
is
|
|
89
|
+
is LuggMapWrapperView -> mapWrapperView = child
|
|
78
90
|
|
|
79
|
-
is
|
|
91
|
+
is LuggMarkerView -> {
|
|
80
92
|
child.delegate = this
|
|
81
93
|
syncMarkerView(child)
|
|
82
94
|
}
|
|
83
95
|
|
|
84
|
-
is
|
|
96
|
+
is LuggPolylineView -> {
|
|
85
97
|
child.delegate = this
|
|
86
98
|
syncPolylineView(child)
|
|
87
99
|
}
|
|
@@ -90,11 +102,11 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
90
102
|
|
|
91
103
|
override fun removeViewAt(index: Int) {
|
|
92
104
|
val view = getChildAt(index)
|
|
93
|
-
if (view is
|
|
105
|
+
if (view is LuggMarkerView) {
|
|
94
106
|
Log.d(TAG, "removing markerView: ${view.name}")
|
|
95
107
|
view.marker?.remove()
|
|
96
108
|
view.marker = null
|
|
97
|
-
} else if (view is
|
|
109
|
+
} else if (view is LuggPolylineView) {
|
|
98
110
|
polylineAnimators[view]?.destroy()
|
|
99
111
|
polylineAnimators.remove(view)
|
|
100
112
|
view.polyline?.remove()
|
|
@@ -156,9 +168,13 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
156
168
|
map.setOnCameraIdleListener(this)
|
|
157
169
|
|
|
158
170
|
applyUiSettings()
|
|
171
|
+
applyZoomLimits()
|
|
159
172
|
applyPadding()
|
|
173
|
+
applyUserLocation()
|
|
160
174
|
processPendingMarkers()
|
|
161
175
|
processPendingPolylines()
|
|
176
|
+
|
|
177
|
+
eventDelegate?.onReady(this)
|
|
162
178
|
}
|
|
163
179
|
|
|
164
180
|
override fun onCameraMoveStarted(reason: Int) {
|
|
@@ -174,8 +190,8 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
174
190
|
override fun onCameraIdle() {
|
|
175
191
|
val map = googleMap ?: return
|
|
176
192
|
val position = map.cameraPosition
|
|
193
|
+
eventDelegate?.onCameraIdle(this, position.target.latitude, position.target.longitude, position.zoom, isDragging)
|
|
177
194
|
isDragging = false
|
|
178
|
-
eventDelegate?.onCameraIdle(this, position.target.latitude, position.target.longitude, position.zoom)
|
|
179
195
|
}
|
|
180
196
|
|
|
181
197
|
private fun applyUiSettings() {
|
|
@@ -187,15 +203,33 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
187
203
|
}
|
|
188
204
|
}
|
|
189
205
|
|
|
206
|
+
private fun applyZoomLimits() {
|
|
207
|
+
googleMap?.apply {
|
|
208
|
+
minZoom?.let { setMinZoomPreference(it) }
|
|
209
|
+
maxZoom?.let { setMaxZoomPreference(it) }
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
190
213
|
private fun applyPadding() {
|
|
191
214
|
googleMap?.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom)
|
|
192
215
|
}
|
|
193
216
|
|
|
217
|
+
@SuppressLint("MissingPermission")
|
|
218
|
+
private fun applyUserLocation() {
|
|
219
|
+
val hasPermission =
|
|
220
|
+
context.checkSelfPermission(
|
|
221
|
+
android.Manifest.permission.ACCESS_FINE_LOCATION
|
|
222
|
+
) == android.content.pm.PackageManager.PERMISSION_GRANTED ||
|
|
223
|
+
context.checkSelfPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION) ==
|
|
224
|
+
android.content.pm.PackageManager.PERMISSION_GRANTED
|
|
225
|
+
googleMap?.isMyLocationEnabled = userLocationEnabled && hasPermission
|
|
226
|
+
}
|
|
227
|
+
|
|
194
228
|
// endregion
|
|
195
229
|
|
|
196
230
|
// region PolylineViewDelegate
|
|
197
231
|
|
|
198
|
-
override fun polylineViewDidUpdate(polylineView:
|
|
232
|
+
override fun polylineViewDidUpdate(polylineView: LuggPolylineView) {
|
|
199
233
|
syncPolylineView(polylineView)
|
|
200
234
|
}
|
|
201
235
|
|
|
@@ -203,7 +237,7 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
203
237
|
|
|
204
238
|
// region MarkerViewDelegate
|
|
205
239
|
|
|
206
|
-
override fun markerViewDidLayout(markerView:
|
|
240
|
+
override fun markerViewDidLayout(markerView: LuggMarkerView) {
|
|
207
241
|
if (googleMap == null) {
|
|
208
242
|
if (!pendingMarkerViews.contains(markerView)) {
|
|
209
243
|
pendingMarkerViews.add(markerView)
|
|
@@ -220,7 +254,7 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
220
254
|
}
|
|
221
255
|
}
|
|
222
256
|
|
|
223
|
-
override fun markerViewDidUpdate(markerView:
|
|
257
|
+
override fun markerViewDidUpdate(markerView: LuggMarkerView) {
|
|
224
258
|
syncMarkerView(markerView)
|
|
225
259
|
}
|
|
226
260
|
|
|
@@ -228,7 +262,7 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
228
262
|
|
|
229
263
|
// region Marker Management
|
|
230
264
|
|
|
231
|
-
private fun syncMarkerView(markerView:
|
|
265
|
+
private fun syncMarkerView(markerView: LuggMarkerView) {
|
|
232
266
|
if (googleMap == null) {
|
|
233
267
|
if (!pendingMarkerViews.contains(markerView)) {
|
|
234
268
|
pendingMarkerViews.add(markerView)
|
|
@@ -262,9 +296,9 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
262
296
|
pendingMarkerViews.clear()
|
|
263
297
|
}
|
|
264
298
|
|
|
265
|
-
private fun addMarkerViewToMap(markerView:
|
|
299
|
+
private fun addMarkerViewToMap(markerView: LuggMarkerView) {
|
|
266
300
|
val map = googleMap ?: run {
|
|
267
|
-
RNLog.w(reactContext, "
|
|
301
|
+
RNLog.w(reactContext, "Lugg: addMarkerViewToMap called without a map")
|
|
268
302
|
return
|
|
269
303
|
}
|
|
270
304
|
|
|
@@ -294,7 +328,7 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
294
328
|
|
|
295
329
|
// region Polyline Management
|
|
296
330
|
|
|
297
|
-
private fun syncPolylineView(polylineView:
|
|
331
|
+
private fun syncPolylineView(polylineView: LuggPolylineView) {
|
|
298
332
|
if (googleMap == null) {
|
|
299
333
|
if (!pendingPolylineViews.contains(polylineView)) {
|
|
300
334
|
pendingPolylineViews.add(polylineView)
|
|
@@ -325,7 +359,7 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
325
359
|
pendingPolylineViews.clear()
|
|
326
360
|
}
|
|
327
361
|
|
|
328
|
-
private fun addPolylineViewToMap(polylineView:
|
|
362
|
+
private fun addPolylineViewToMap(polylineView: LuggPolylineView) {
|
|
329
363
|
val map = googleMap ?: return
|
|
330
364
|
|
|
331
365
|
val options = PolylineOptions()
|
|
@@ -354,7 +388,7 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
354
388
|
if (value.isNullOrEmpty()) return
|
|
355
389
|
|
|
356
390
|
if (mapView != null) {
|
|
357
|
-
RNLog.w(reactContext, "
|
|
391
|
+
RNLog.w(reactContext, "Lugg: mapId cannot be changed after map is initialized")
|
|
358
392
|
return
|
|
359
393
|
}
|
|
360
394
|
|
|
@@ -390,6 +424,25 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
390
424
|
googleMap?.uiSettings?.isTiltGesturesEnabled = enabled
|
|
391
425
|
}
|
|
392
426
|
|
|
427
|
+
fun setUserLocationEnabled(enabled: Boolean) {
|
|
428
|
+
userLocationEnabled = enabled
|
|
429
|
+
applyUserLocation()
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
fun setMinZoom(zoom: Double) {
|
|
433
|
+
minZoom = if (zoom > 0) zoom.toFloat() else null
|
|
434
|
+
googleMap?.let { map ->
|
|
435
|
+
minZoom?.let { map.setMinZoomPreference(it) } ?: map.resetMinMaxZoomPreference()
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
fun setMaxZoom(zoom: Double) {
|
|
440
|
+
maxZoom = if (zoom > 0) zoom.toFloat() else null
|
|
441
|
+
googleMap?.let { map ->
|
|
442
|
+
maxZoom?.let { map.setMaxZoomPreference(it) } ?: map.resetMinMaxZoomPreference()
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
393
446
|
fun setMapPadding(top: Int, left: Int, bottom: Int, right: Int) {
|
|
394
447
|
paddingTop = top
|
|
395
448
|
paddingLeft = left
|
|
@@ -432,7 +485,7 @@ class LuggMapsGoogleMapView(private val reactContext: ThemedReactContext) :
|
|
|
432
485
|
// endregion
|
|
433
486
|
|
|
434
487
|
companion object {
|
|
435
|
-
private const val TAG = "
|
|
488
|
+
private const val TAG = "Lugg"
|
|
436
489
|
const val DEMO_MAP_ID = "DEMO_MAP_ID"
|
|
437
490
|
}
|
|
438
491
|
}
|
|
@@ -5,29 +5,30 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
5
5
|
import com.facebook.react.module.annotations.ReactModule
|
|
6
6
|
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
7
7
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
|
-
import com.facebook.react.uimanager.UIManagerHelper
|
|
9
8
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
10
9
|
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
11
10
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
12
|
-
import com.facebook.react.viewmanagers.
|
|
13
|
-
import com.facebook.react.viewmanagers.
|
|
11
|
+
import com.facebook.react.viewmanagers.LuggGoogleMapViewManagerDelegate
|
|
12
|
+
import com.facebook.react.viewmanagers.LuggGoogleMapViewManagerInterface
|
|
14
13
|
import com.google.android.gms.maps.model.LatLng
|
|
15
14
|
import com.luggmaps.events.CameraIdleEvent
|
|
16
15
|
import com.luggmaps.events.CameraMoveEvent
|
|
16
|
+
import com.luggmaps.events.ReadyEvent
|
|
17
|
+
import com.luggmaps.extensions.dispatchEvent
|
|
17
18
|
|
|
18
|
-
@ReactModule(name =
|
|
19
|
-
class
|
|
20
|
-
ViewGroupManager<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
private val delegate: ViewManagerDelegate<
|
|
19
|
+
@ReactModule(name = LuggGoogleMapViewManager.NAME)
|
|
20
|
+
class LuggGoogleMapViewManager :
|
|
21
|
+
ViewGroupManager<LuggGoogleMapView>(),
|
|
22
|
+
LuggGoogleMapViewManagerInterface<LuggGoogleMapView>,
|
|
23
|
+
LuggGoogleMapViewEventDelegate {
|
|
24
|
+
private val delegate: ViewManagerDelegate<LuggGoogleMapView> = LuggGoogleMapViewManagerDelegate(this)
|
|
24
25
|
|
|
25
|
-
override fun getDelegate(): ViewManagerDelegate<
|
|
26
|
+
override fun getDelegate(): ViewManagerDelegate<LuggGoogleMapView> = delegate
|
|
26
27
|
|
|
27
28
|
override fun getName(): String = NAME
|
|
28
29
|
|
|
29
|
-
override fun createViewInstance(context: ThemedReactContext):
|
|
30
|
-
val view =
|
|
30
|
+
override fun createViewInstance(context: ThemedReactContext): LuggGoogleMapView {
|
|
31
|
+
val view = LuggGoogleMapView(context)
|
|
31
32
|
view.eventDelegate = this
|
|
32
33
|
return view
|
|
33
34
|
}
|
|
@@ -35,38 +36,41 @@ class LuggMapsGoogleMapViewManager :
|
|
|
35
36
|
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> =
|
|
36
37
|
mapOf(
|
|
37
38
|
"topCameraMove" to mapOf("registrationName" to "onCameraMove"),
|
|
38
|
-
"topCameraIdle" to mapOf("registrationName" to "onCameraIdle")
|
|
39
|
+
"topCameraIdle" to mapOf("registrationName" to "onCameraIdle"),
|
|
40
|
+
"topReady" to mapOf("registrationName" to "onReady")
|
|
39
41
|
)
|
|
40
42
|
|
|
41
43
|
override fun onCameraMove(
|
|
42
|
-
view:
|
|
44
|
+
view: LuggGoogleMapView,
|
|
43
45
|
latitude: Double,
|
|
44
46
|
longitude: Double,
|
|
45
47
|
zoom: Float,
|
|
46
|
-
|
|
48
|
+
gesture: Boolean
|
|
47
49
|
) {
|
|
48
|
-
|
|
49
|
-
view.context as ThemedReactContext,
|
|
50
|
-
view.id
|
|
51
|
-
)
|
|
52
|
-
eventDispatcher?.dispatchEvent(CameraMoveEvent(UIManagerHelper.getSurfaceId(view), view.id, latitude, longitude, zoom, dragging))
|
|
50
|
+
view.dispatchEvent(CameraMoveEvent(view, latitude, longitude, zoom, gesture))
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
override fun onCameraIdle(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
override fun onCameraIdle(
|
|
54
|
+
view: LuggGoogleMapView,
|
|
55
|
+
latitude: Double,
|
|
56
|
+
longitude: Double,
|
|
57
|
+
zoom: Float,
|
|
58
|
+
gesture: Boolean
|
|
59
|
+
) {
|
|
60
|
+
view.dispatchEvent(CameraIdleEvent(view, latitude, longitude, zoom, gesture))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
override fun onReady(view: LuggGoogleMapView) {
|
|
64
|
+
view.dispatchEvent(ReadyEvent(view))
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
@ReactProp(name = "mapId")
|
|
64
|
-
override fun setMapId(view:
|
|
68
|
+
override fun setMapId(view: LuggGoogleMapView, value: String?) {
|
|
65
69
|
view.setMapId(value)
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
@ReactProp(name = "initialCoordinate")
|
|
69
|
-
override fun setInitialCoordinate(view:
|
|
73
|
+
override fun setInitialCoordinate(view: LuggGoogleMapView, value: ReadableMap?) {
|
|
70
74
|
value?.let {
|
|
71
75
|
val latitude = if (it.hasKey("latitude")) it.getDouble("latitude") else 0.0
|
|
72
76
|
val longitude = if (it.hasKey("longitude")) it.getDouble("longitude") else 0.0
|
|
@@ -75,32 +79,47 @@ class LuggMapsGoogleMapViewManager :
|
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
@ReactProp(name = "initialZoom", defaultDouble = 10.0)
|
|
78
|
-
override fun setInitialZoom(view:
|
|
82
|
+
override fun setInitialZoom(view: LuggGoogleMapView, value: Double) {
|
|
79
83
|
view.setInitialZoom(value)
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
@ReactProp(name = "zoomEnabled", defaultBoolean = true)
|
|
83
|
-
override fun setZoomEnabled(view:
|
|
87
|
+
override fun setZoomEnabled(view: LuggGoogleMapView, value: Boolean) {
|
|
84
88
|
view.setZoomEnabled(value)
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
@ReactProp(name = "scrollEnabled", defaultBoolean = true)
|
|
88
|
-
override fun setScrollEnabled(view:
|
|
92
|
+
override fun setScrollEnabled(view: LuggGoogleMapView, value: Boolean) {
|
|
89
93
|
view.setScrollEnabled(value)
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
@ReactProp(name = "rotateEnabled", defaultBoolean = true)
|
|
93
|
-
override fun setRotateEnabled(view:
|
|
97
|
+
override fun setRotateEnabled(view: LuggGoogleMapView, value: Boolean) {
|
|
94
98
|
view.setRotateEnabled(value)
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
@ReactProp(name = "pitchEnabled", defaultBoolean = true)
|
|
98
|
-
override fun setPitchEnabled(view:
|
|
102
|
+
override fun setPitchEnabled(view: LuggGoogleMapView, value: Boolean) {
|
|
99
103
|
view.setPitchEnabled(value)
|
|
100
104
|
}
|
|
101
105
|
|
|
106
|
+
@ReactProp(name = "userLocationEnabled", defaultBoolean = false)
|
|
107
|
+
override fun setUserLocationEnabled(view: LuggGoogleMapView, value: Boolean) {
|
|
108
|
+
view.setUserLocationEnabled(value)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@ReactProp(name = "minZoom")
|
|
112
|
+
override fun setMinZoom(view: LuggGoogleMapView, value: Double) {
|
|
113
|
+
view.setMinZoom(value)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@ReactProp(name = "maxZoom")
|
|
117
|
+
override fun setMaxZoom(view: LuggGoogleMapView, value: Double) {
|
|
118
|
+
view.setMaxZoom(value)
|
|
119
|
+
}
|
|
120
|
+
|
|
102
121
|
@ReactProp(name = "padding")
|
|
103
|
-
override fun setPadding(view:
|
|
122
|
+
override fun setPadding(view: LuggGoogleMapView, value: ReadableMap?) {
|
|
104
123
|
value?.let {
|
|
105
124
|
val top = if (it.hasKey("top")) it.getDouble("top").toFloat().dpToPx().toInt() else 0
|
|
106
125
|
val left = if (it.hasKey("left")) it.getDouble("left").toFloat().dpToPx().toInt() else 0
|
|
@@ -110,13 +129,13 @@ class LuggMapsGoogleMapViewManager :
|
|
|
110
129
|
}
|
|
111
130
|
}
|
|
112
131
|
|
|
113
|
-
override fun onDropViewInstance(view:
|
|
132
|
+
override fun onDropViewInstance(view: LuggGoogleMapView) {
|
|
114
133
|
super.onDropViewInstance(view)
|
|
115
134
|
view.onDropViewInstance()
|
|
116
135
|
}
|
|
117
136
|
|
|
118
137
|
override fun moveCamera(
|
|
119
|
-
view:
|
|
138
|
+
view: LuggGoogleMapView,
|
|
120
139
|
latitude: Double,
|
|
121
140
|
longitude: Double,
|
|
122
141
|
zoom: Double,
|
|
@@ -125,7 +144,7 @@ class LuggMapsGoogleMapViewManager :
|
|
|
125
144
|
view.moveCamera(latitude, longitude, zoom, duration.toInt())
|
|
126
145
|
}
|
|
127
146
|
|
|
128
|
-
override fun fitCoordinates(view:
|
|
147
|
+
override fun fitCoordinates(view: LuggGoogleMapView, coordinates: ReadableArray?, padding: Double, duration: Double) {
|
|
129
148
|
val coords = mutableListOf<LatLng>()
|
|
130
149
|
coordinates?.let {
|
|
131
150
|
for (i in 0 until it.size()) {
|
|
@@ -139,6 +158,6 @@ class LuggMapsGoogleMapViewManager :
|
|
|
139
158
|
}
|
|
140
159
|
|
|
141
160
|
companion object {
|
|
142
|
-
const val NAME = "
|
|
161
|
+
const val NAME = "LuggGoogleMapView"
|
|
143
162
|
}
|
|
144
163
|
}
|
|
@@ -5,7 +5,7 @@ import com.facebook.react.uimanager.ThemedReactContext
|
|
|
5
5
|
import com.facebook.react.views.view.ReactViewGroup
|
|
6
6
|
|
|
7
7
|
@SuppressLint("ViewConstructor")
|
|
8
|
-
class
|
|
8
|
+
class LuggMapWrapperView(context: ThemedReactContext) : ReactViewGroup(context) {
|
|
9
9
|
|
|
10
10
|
override fun requestLayout() {
|
|
11
11
|
super.requestLayout()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package com.luggmaps
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
6
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
7
|
+
import com.facebook.react.viewmanagers.LuggMapWrapperViewManagerDelegate
|
|
8
|
+
import com.facebook.react.viewmanagers.LuggMapWrapperViewManagerInterface
|
|
9
|
+
|
|
10
|
+
@ReactModule(name = LuggMapWrapperViewManager.NAME)
|
|
11
|
+
class LuggMapWrapperViewManager :
|
|
12
|
+
ViewGroupManager<LuggMapWrapperView>(),
|
|
13
|
+
LuggMapWrapperViewManagerInterface<LuggMapWrapperView> {
|
|
14
|
+
private val delegate: ViewManagerDelegate<LuggMapWrapperView> = LuggMapWrapperViewManagerDelegate(this)
|
|
15
|
+
|
|
16
|
+
override fun getDelegate(): ViewManagerDelegate<LuggMapWrapperView> = delegate
|
|
17
|
+
|
|
18
|
+
override fun getName(): String = NAME
|
|
19
|
+
|
|
20
|
+
override fun createViewInstance(context: ThemedReactContext): LuggMapWrapperView = LuggMapWrapperView(context)
|
|
21
|
+
|
|
22
|
+
companion object {
|
|
23
|
+
const val NAME = "LuggMapWrapperView"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -7,12 +7,12 @@ import androidx.core.view.isNotEmpty
|
|
|
7
7
|
import com.facebook.react.views.view.ReactViewGroup
|
|
8
8
|
import com.google.android.gms.maps.model.AdvancedMarker
|
|
9
9
|
|
|
10
|
-
interface
|
|
11
|
-
fun markerViewDidUpdate(markerView:
|
|
12
|
-
fun markerViewDidLayout(markerView:
|
|
10
|
+
interface LuggMarkerViewDelegate {
|
|
11
|
+
fun markerViewDidUpdate(markerView: LuggMarkerView)
|
|
12
|
+
fun markerViewDidLayout(markerView: LuggMarkerView)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
class
|
|
15
|
+
class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
16
16
|
var name: String? = null
|
|
17
17
|
private set
|
|
18
18
|
|
|
@@ -26,7 +26,7 @@ class LuggMapsMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
26
26
|
var description: String? = null
|
|
27
27
|
private set
|
|
28
28
|
|
|
29
|
-
var delegate:
|
|
29
|
+
var delegate: LuggMarkerViewDelegate? = null
|
|
30
30
|
var marker: AdvancedMarker? = null
|
|
31
31
|
|
|
32
32
|
var anchorX: Float = 0.5f
|
|
@@ -129,6 +129,6 @@ class LuggMapsMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
companion object {
|
|
132
|
-
private const val TAG = "
|
|
132
|
+
private const val TAG = "Lugg"
|
|
133
133
|
}
|
|
134
134
|
}
|
package/android/src/main/java/com/luggmaps/{LuggMapsMarkerViewManager.kt → LuggMarkerViewManager.kt}
RENAMED
|
@@ -7,31 +7,31 @@ import com.facebook.react.uimanager.ThemedReactContext
|
|
|
7
7
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
8
8
|
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
9
9
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
10
|
-
import com.facebook.react.viewmanagers.
|
|
11
|
-
import com.facebook.react.viewmanagers.
|
|
10
|
+
import com.facebook.react.viewmanagers.LuggMarkerViewManagerDelegate
|
|
11
|
+
import com.facebook.react.viewmanagers.LuggMarkerViewManagerInterface
|
|
12
12
|
|
|
13
|
-
@ReactModule(name =
|
|
14
|
-
class
|
|
15
|
-
ViewGroupManager<
|
|
16
|
-
|
|
17
|
-
private val delegate: ViewManagerDelegate<
|
|
13
|
+
@ReactModule(name = LuggMarkerViewManager.NAME)
|
|
14
|
+
class LuggMarkerViewManager :
|
|
15
|
+
ViewGroupManager<LuggMarkerView>(),
|
|
16
|
+
LuggMarkerViewManagerInterface<LuggMarkerView> {
|
|
17
|
+
private val delegate: ViewManagerDelegate<LuggMarkerView> = LuggMarkerViewManagerDelegate(this)
|
|
18
18
|
|
|
19
|
-
override fun getDelegate(): ViewManagerDelegate<
|
|
19
|
+
override fun getDelegate(): ViewManagerDelegate<LuggMarkerView> = delegate
|
|
20
20
|
override fun getName(): String = NAME
|
|
21
|
-
override fun createViewInstance(context: ThemedReactContext):
|
|
21
|
+
override fun createViewInstance(context: ThemedReactContext): LuggMarkerView = LuggMarkerView(context)
|
|
22
22
|
|
|
23
|
-
override fun onDropViewInstance(view:
|
|
23
|
+
override fun onDropViewInstance(view: LuggMarkerView) {
|
|
24
24
|
super.onDropViewInstance(view)
|
|
25
25
|
view.onDropViewInstance()
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
override fun onAfterUpdateTransaction(view:
|
|
28
|
+
override fun onAfterUpdateTransaction(view: LuggMarkerView) {
|
|
29
29
|
super.onAfterUpdateTransaction(view)
|
|
30
30
|
view.onAfterUpdateTransaction()
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
@ReactProp(name = "coordinate")
|
|
34
|
-
override fun setCoordinate(view:
|
|
34
|
+
override fun setCoordinate(view: LuggMarkerView, value: ReadableMap?) {
|
|
35
35
|
value?.let {
|
|
36
36
|
val latitude = if (it.hasKey("latitude")) it.getDouble("latitude") else 0.0
|
|
37
37
|
val longitude = if (it.hasKey("longitude")) it.getDouble("longitude") else 0.0
|
|
@@ -40,22 +40,22 @@ class LuggMapsMarkerViewManager :
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
@ReactProp(name = "name")
|
|
43
|
-
override fun setName(view:
|
|
43
|
+
override fun setName(view: LuggMarkerView, value: String?) {
|
|
44
44
|
view.setName(value)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
@ReactProp(name = "title")
|
|
48
|
-
override fun setTitle(view:
|
|
48
|
+
override fun setTitle(view: LuggMarkerView, value: String?) {
|
|
49
49
|
view.setTitle(value)
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
@ReactProp(name = "description")
|
|
53
|
-
override fun setDescription(view:
|
|
53
|
+
override fun setDescription(view: LuggMarkerView, value: String?) {
|
|
54
54
|
view.setDescription(value)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
@ReactProp(name = "anchor")
|
|
58
|
-
override fun setAnchor(view:
|
|
58
|
+
override fun setAnchor(view: LuggMarkerView, value: ReadableMap?) {
|
|
59
59
|
value?.let {
|
|
60
60
|
val x = if (it.hasKey("x")) it.getDouble("x") else 0.5
|
|
61
61
|
val y = if (it.hasKey("y")) it.getDouble("y") else 1.0
|
|
@@ -64,6 +64,6 @@ class LuggMapsMarkerViewManager :
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
companion object {
|
|
67
|
-
const val NAME = "
|
|
67
|
+
const val NAME = "LuggMarkerView"
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -5,9 +5,9 @@ import com.facebook.react.bridge.NativeModule
|
|
|
5
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
6
|
import com.facebook.react.uimanager.ViewManager
|
|
7
7
|
|
|
8
|
-
class
|
|
8
|
+
class LuggPackage : ReactPackage {
|
|
9
9
|
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
|
|
10
|
-
listOf(
|
|
10
|
+
listOf(LuggGoogleMapViewManager(), LuggMarkerViewManager(), LuggMapWrapperViewManager(), LuggPolylineViewManager())
|
|
11
11
|
|
|
12
12
|
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> = emptyList()
|
|
13
13
|
}
|
|
@@ -8,11 +8,11 @@ import com.google.android.gms.maps.model.Polyline
|
|
|
8
8
|
import com.google.android.gms.maps.model.StrokeStyle
|
|
9
9
|
import com.google.android.gms.maps.model.StyleSpan
|
|
10
10
|
|
|
11
|
-
interface
|
|
12
|
-
fun polylineViewDidUpdate(polylineView:
|
|
11
|
+
interface LuggPolylineViewDelegate {
|
|
12
|
+
fun polylineViewDidUpdate(polylineView: LuggPolylineView)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
class
|
|
15
|
+
class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
16
16
|
var coordinates: List<LatLng> = emptyList()
|
|
17
17
|
private set
|
|
18
18
|
|
|
@@ -28,7 +28,7 @@ class LuggMapsPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
28
28
|
var cachedSpans: List<StyleSpan>? = null
|
|
29
29
|
private set
|
|
30
30
|
|
|
31
|
-
var delegate:
|
|
31
|
+
var delegate: LuggPolylineViewDelegate? = null
|
|
32
32
|
var polyline: Polyline? = null
|
|
33
33
|
|
|
34
34
|
init {
|