react-native-google-maps-plus 1.1.0-dev.1 → 1.1.0-dev.3
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/RNGoogleMapsPlus.podspec +2 -0
- package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +38 -103
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +3 -3
- package/android/src/main/java/com/rngooglemapsplus/MapCircleBuilder.kt +16 -2
- package/android/src/main/java/com/rngooglemapsplus/MapMarkerBuilder.kt +48 -27
- package/android/src/main/java/com/rngooglemapsplus/MapPolygonBuilder.kt +18 -1
- package/android/src/main/java/com/rngooglemapsplus/MapPolylineBuilder.kt.kt +26 -9
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +48 -72
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNMarkerExtension.kt +17 -0
- package/ios/GoogleMapViewImpl.swift +94 -212
- package/ios/LocationHandler.swift +2 -10
- package/ios/MapCircleBuilder.swift +23 -8
- package/ios/MapHelper.swift +6 -4
- package/ios/MapMarkerBuilder.swift +55 -48
- package/ios/MapPolygonBuilder.swift +25 -7
- package/ios/MapPolylineBuilder.swift +27 -11
- package/ios/RNGoogleMapsPlusView.swift +9 -15
- package/ios/extensions/RNCircle+Extension.swift +0 -13
- package/ios/extensions/RNMarker+Extension.swift +6 -5
- package/ios/extensions/RNPolygon+Extension.swift.swift +2 -19
- package/ios/extensions/RNPolyline+Extension.swift.swift +1 -26
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts +2 -3
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +9 -2
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +14 -15
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +2 -4
- package/nitrogen/generated/android/c++/JRNCircle.hpp +4 -4
- package/nitrogen/generated/android/c++/JRNMapZoomConfig.hpp +57 -0
- package/nitrogen/generated/android/c++/JRNMarker.hpp +6 -12
- package/nitrogen/generated/android/c++/JRNMarkerSvg.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +2 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +1 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNCircle.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapZoomConfig.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarker.kt +1 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarkerSvg.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/views/HybridRNGoogleMapsPlusViewManager.kt +1 -1
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.cpp +13 -13
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +75 -33
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +6 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +11 -12
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +4 -9
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +1 -2
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +46 -94
- package/nitrogen/generated/ios/swift/RNCamera.swift +1 -8
- package/nitrogen/generated/ios/swift/RNCircle.swift +5 -17
- package/nitrogen/generated/ios/swift/RNInitialProps.swift +1 -8
- package/nitrogen/generated/ios/swift/RNLocationConfig.swift +2 -16
- package/nitrogen/generated/ios/swift/RNMapZoomConfig.swift +70 -0
- package/nitrogen/generated/ios/swift/RNMarker.swift +18 -35
- package/nitrogen/generated/ios/swift/RNMarkerSvg.swift +57 -0
- package/nitrogen/generated/ios/swift/RNPolygon.swift +11 -15
- package/nitrogen/generated/ios/swift/RNPolyline.swift +11 -15
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +2 -4
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +5 -4
- package/nitrogen/generated/shared/c++/RNCircle.hpp +5 -5
- package/nitrogen/generated/shared/c++/RNMapZoomConfig.hpp +71 -0
- package/nitrogen/generated/shared/c++/RNMarker.hpp +8 -13
- package/nitrogen/generated/shared/c++/RNMarkerSvg.hpp +75 -0
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +7 -19
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +2 -2
- package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +1 -2
- package/package.json +13 -13
- package/src/RNGoogleMapsPlusView.nitro.ts +2 -2
- package/src/types.ts +11 -2
package/RNGoogleMapsPlus.podspec
CHANGED
|
@@ -32,7 +32,7 @@ class GoogleMapsViewImpl(
|
|
|
32
32
|
val reactContext: ThemedReactContext,
|
|
33
33
|
val locationHandler: LocationHandler,
|
|
34
34
|
val playServiceHandler: PlayServicesHandler,
|
|
35
|
-
val markerBuilder:
|
|
35
|
+
val markerBuilder: MapMarkerBuilder,
|
|
36
36
|
) : FrameLayout(reactContext),
|
|
37
37
|
GoogleMap.OnCameraMoveStartedListener,
|
|
38
38
|
GoogleMap.OnCameraMoveListener,
|
|
@@ -293,11 +293,9 @@ class GoogleMapsViewImpl(
|
|
|
293
293
|
userInterfaceStyle?.let {
|
|
294
294
|
googleMap?.mapColorScheme = it
|
|
295
295
|
}
|
|
296
|
-
|
|
297
|
-
googleMap?.setMinZoomPreference(it.toFloat())
|
|
298
|
-
|
|
299
|
-
maxZoomLevel?.let {
|
|
300
|
-
googleMap?.setMaxZoomPreference(it.toFloat())
|
|
296
|
+
mapZoomConfig?.let {
|
|
297
|
+
googleMap?.setMinZoomPreference(it.min?.toFloat() ?: 2.0f)
|
|
298
|
+
googleMap?.setMaxZoomPreference(it.max?.toFloat() ?: 21.0f)
|
|
301
299
|
}
|
|
302
300
|
}
|
|
303
301
|
|
|
@@ -340,56 +338,34 @@ class GoogleMapsViewImpl(
|
|
|
340
338
|
set(value) {
|
|
341
339
|
field = value
|
|
342
340
|
onUi {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
v.zoomGesturesEnabled?.let { isZoomGesturesEnabled = it }
|
|
361
|
-
}
|
|
341
|
+
googleMap?.uiSettings?.apply {
|
|
342
|
+
setAllGesturesEnabled(value?.allGesturesEnabled ?: true)
|
|
343
|
+
isCompassEnabled = value?.compassEnabled ?: false
|
|
344
|
+
isIndoorLevelPickerEnabled = value?.indoorLevelPickerEnabled ?: false
|
|
345
|
+
isMapToolbarEnabled = value?.mapToolbarEnabled ?: false
|
|
346
|
+
|
|
347
|
+
val myLocationEnabled = value?.myLocationButtonEnabled ?: false
|
|
348
|
+
googleMap?.setLocationSource(if (myLocationEnabled) locationHandler else null)
|
|
349
|
+
isMyLocationButtonEnabled = myLocationEnabled
|
|
350
|
+
|
|
351
|
+
isRotateGesturesEnabled = value?.rotateEnabled ?: true
|
|
352
|
+
isScrollGesturesEnabled = value?.scrollEnabled ?: true
|
|
353
|
+
isScrollGesturesEnabledDuringRotateOrZoom =
|
|
354
|
+
value?.scrollDuringRotateOrZoomEnabled ?: true
|
|
355
|
+
isTiltGesturesEnabled = value?.tiltEnabled ?: true
|
|
356
|
+
isZoomControlsEnabled = value?.zoomControlsEnabled ?: false
|
|
357
|
+
isZoomGesturesEnabled = value?.zoomGesturesEnabled ?: false
|
|
362
358
|
}
|
|
363
|
-
?: run {
|
|
364
|
-
googleMap?.uiSettings?.apply {
|
|
365
|
-
setAllGesturesEnabled(true)
|
|
366
|
-
isCompassEnabled = false
|
|
367
|
-
isIndoorLevelPickerEnabled = false
|
|
368
|
-
isMapToolbarEnabled = false
|
|
369
|
-
isMyLocationButtonEnabled = false
|
|
370
|
-
googleMap?.setLocationSource(null)
|
|
371
|
-
isRotateGesturesEnabled = true
|
|
372
|
-
isScrollGesturesEnabled = true
|
|
373
|
-
isScrollGesturesEnabledDuringRotateOrZoom = true
|
|
374
|
-
isTiltGesturesEnabled = true
|
|
375
|
-
isZoomControlsEnabled = false
|
|
376
|
-
isZoomGesturesEnabled = false
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
359
|
}
|
|
380
360
|
}
|
|
381
361
|
|
|
382
362
|
@SuppressLint("MissingPermission")
|
|
383
363
|
var myLocationEnabled: Boolean? = null
|
|
384
364
|
set(value) {
|
|
365
|
+
field = value
|
|
385
366
|
onUi {
|
|
386
367
|
try {
|
|
387
|
-
|
|
388
|
-
googleMap?.isMyLocationEnabled = it
|
|
389
|
-
}
|
|
390
|
-
?: run {
|
|
391
|
-
googleMap?.isMyLocationEnabled = false
|
|
392
|
-
}
|
|
368
|
+
googleMap?.isMyLocationEnabled = value ?: false
|
|
393
369
|
} catch (se: SecurityException) {
|
|
394
370
|
onLocationError?.invoke(RNLocationErrorCode.PERMISSION_DENIED)
|
|
395
371
|
} catch (ex: Exception) {
|
|
@@ -403,12 +379,7 @@ class GoogleMapsViewImpl(
|
|
|
403
379
|
set(value) {
|
|
404
380
|
field = value
|
|
405
381
|
onUi {
|
|
406
|
-
|
|
407
|
-
googleMap?.isBuildingsEnabled = it
|
|
408
|
-
}
|
|
409
|
-
?: run {
|
|
410
|
-
googleMap?.isBuildingsEnabled = false
|
|
411
|
-
}
|
|
382
|
+
googleMap?.isBuildingsEnabled = value ?: false
|
|
412
383
|
}
|
|
413
384
|
}
|
|
414
385
|
|
|
@@ -416,11 +387,7 @@ class GoogleMapsViewImpl(
|
|
|
416
387
|
set(value) {
|
|
417
388
|
field = value
|
|
418
389
|
onUi {
|
|
419
|
-
|
|
420
|
-
googleMap?.isTrafficEnabled = it
|
|
421
|
-
} ?: run {
|
|
422
|
-
googleMap?.isTrafficEnabled = false
|
|
423
|
-
}
|
|
390
|
+
googleMap?.isTrafficEnabled = value ?: false
|
|
424
391
|
}
|
|
425
392
|
}
|
|
426
393
|
|
|
@@ -428,12 +395,7 @@ class GoogleMapsViewImpl(
|
|
|
428
395
|
set(value) {
|
|
429
396
|
field = value
|
|
430
397
|
onUi {
|
|
431
|
-
|
|
432
|
-
googleMap?.isIndoorEnabled = it
|
|
433
|
-
}
|
|
434
|
-
?: run {
|
|
435
|
-
googleMap?.isIndoorEnabled = false
|
|
436
|
-
}
|
|
398
|
+
googleMap?.isIndoorEnabled = value ?: false
|
|
437
399
|
}
|
|
438
400
|
}
|
|
439
401
|
|
|
@@ -449,52 +411,29 @@ class GoogleMapsViewImpl(
|
|
|
449
411
|
set(value) {
|
|
450
412
|
field = value
|
|
451
413
|
onUi {
|
|
452
|
-
|
|
453
|
-
googleMap?.mapColorScheme = it
|
|
454
|
-
} ?: run {
|
|
455
|
-
googleMap?.mapColorScheme = MapColorScheme.FOLLOW_SYSTEM
|
|
456
|
-
}
|
|
414
|
+
googleMap?.mapColorScheme = value ?: MapColorScheme.FOLLOW_SYSTEM
|
|
457
415
|
}
|
|
458
416
|
}
|
|
459
417
|
|
|
460
|
-
var
|
|
418
|
+
var mapZoomConfig: RNMapZoomConfig? = null
|
|
461
419
|
set(value) {
|
|
462
420
|
field = value
|
|
463
421
|
onUi {
|
|
464
|
-
value?.
|
|
465
|
-
|
|
466
|
-
} ?: run {
|
|
467
|
-
googleMap?.setMinZoomPreference(2.0f)
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
var maxZoomLevel: Double? = null
|
|
473
|
-
set(value) {
|
|
474
|
-
field = value
|
|
475
|
-
onUi {
|
|
476
|
-
value?.let {
|
|
477
|
-
googleMap?.setMaxZoomPreference(it.toFloat())
|
|
478
|
-
} ?: run {
|
|
479
|
-
googleMap?.setMaxZoomPreference(21.0f)
|
|
480
|
-
}
|
|
422
|
+
googleMap?.setMinZoomPreference(value?.min?.toFloat() ?: 2.0f)
|
|
423
|
+
googleMap?.setMaxZoomPreference(value?.max?.toFloat() ?: 21.0f)
|
|
481
424
|
}
|
|
482
425
|
}
|
|
483
426
|
|
|
484
427
|
var mapPadding: RNMapPadding? = null
|
|
485
428
|
set(value) {
|
|
486
429
|
field = value
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
)
|
|
495
|
-
}
|
|
496
|
-
} ?: run {
|
|
497
|
-
googleMap?.setPadding(0, 0, 0, 0)
|
|
430
|
+
onUi {
|
|
431
|
+
googleMap?.setPadding(
|
|
432
|
+
value?.left?.dpToPx()?.toInt() ?: 0,
|
|
433
|
+
value?.top?.dpToPx()?.toInt() ?: 0,
|
|
434
|
+
value?.right?.dpToPx()?.toInt() ?: 0,
|
|
435
|
+
value?.bottom?.dpToPx()?.toInt() ?: 0,
|
|
436
|
+
)
|
|
498
437
|
}
|
|
499
438
|
}
|
|
500
439
|
|
|
@@ -502,11 +441,7 @@ class GoogleMapsViewImpl(
|
|
|
502
441
|
set(value) {
|
|
503
442
|
field = value
|
|
504
443
|
onUi {
|
|
505
|
-
|
|
506
|
-
googleMap?.mapType = it
|
|
507
|
-
} ?: run {
|
|
508
|
-
googleMap?.mapType = 1
|
|
509
|
-
}
|
|
444
|
+
googleMap?.mapType = value ?: 1
|
|
510
445
|
}
|
|
511
446
|
}
|
|
512
447
|
|
|
@@ -38,19 +38,19 @@ class LocationHandler(
|
|
|
38
38
|
|
|
39
39
|
var priority: Int? = PRIORITY_DEFAULT
|
|
40
40
|
set(value) {
|
|
41
|
-
field = value
|
|
41
|
+
field = value ?: PRIORITY_DEFAULT
|
|
42
42
|
start()
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
var interval: Long? = INTERVAL_DEFAULT
|
|
46
46
|
set(value) {
|
|
47
|
-
field = value
|
|
47
|
+
field = value ?: INTERVAL_DEFAULT
|
|
48
48
|
buildLocationRequest()
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
var minUpdateInterval: Long? = MIN_UPDATE_INTERVAL
|
|
52
52
|
set(value) {
|
|
53
|
-
field = value
|
|
53
|
+
field = value ?: MIN_UPDATE_INTERVAL
|
|
54
54
|
buildLocationRequest()
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
package com.rngooglemapsplus
|
|
2
2
|
|
|
3
|
+
import android.graphics.Color
|
|
3
4
|
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
5
|
+
import com.google.android.gms.maps.model.Circle
|
|
4
6
|
import com.google.android.gms.maps.model.CircleOptions
|
|
5
7
|
import com.google.android.gms.maps.model.LatLng
|
|
6
8
|
import com.rngooglemapsplus.extensions.toColor
|
|
7
9
|
|
|
8
10
|
class MapCircleBuilder {
|
|
9
|
-
fun
|
|
11
|
+
fun build(circle: RNCircle): CircleOptions =
|
|
10
12
|
CircleOptions().apply {
|
|
11
13
|
center(LatLng(circle.center.latitude, circle.center.longitude))
|
|
12
|
-
circle.radius
|
|
14
|
+
radius(circle.radius)
|
|
13
15
|
circle.strokeWidth?.let { strokeWidth(it.dpToPx()) }
|
|
14
16
|
circle.strokeColor?.let { strokeColor(it.toColor()) }
|
|
15
17
|
circle.fillColor?.let { fillColor(it.toColor()) }
|
|
16
18
|
circle.pressable?.let { clickable(it) }
|
|
17
19
|
circle.zIndex?.let { zIndex(it.toFloat()) }
|
|
18
20
|
}
|
|
21
|
+
|
|
22
|
+
fun update(
|
|
23
|
+
circle: Circle,
|
|
24
|
+
next: RNCircle,
|
|
25
|
+
) {
|
|
26
|
+
circle.center = LatLng(next.center.latitude, next.center.longitude)
|
|
27
|
+
circle.radius = next.radius
|
|
28
|
+
circle.strokeWidth = next.strokeWidth?.dpToPx() ?: 1f
|
|
29
|
+
circle.strokeColor = next.strokeColor?.toColor() ?: Color.BLACK
|
|
30
|
+
circle.fillColor = next.fillColor?.toColor() ?: Color.TRANSPARENT
|
|
31
|
+
circle.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
32
|
+
}
|
|
19
33
|
}
|
|
@@ -9,7 +9,10 @@ import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
|
9
9
|
import com.google.android.gms.maps.model.BitmapDescriptor
|
|
10
10
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory
|
|
11
11
|
import com.google.android.gms.maps.model.LatLng
|
|
12
|
+
import com.google.android.gms.maps.model.Marker
|
|
12
13
|
import com.google.android.gms.maps.model.MarkerOptions
|
|
14
|
+
import com.rngooglemapsplus.extensions.markerStyleEquals
|
|
15
|
+
import com.rngooglemapsplus.extensions.styleHash
|
|
13
16
|
import kotlinx.coroutines.CoroutineScope
|
|
14
17
|
import kotlinx.coroutines.Dispatchers
|
|
15
18
|
import kotlinx.coroutines.Job
|
|
@@ -19,7 +22,7 @@ import kotlinx.coroutines.launch
|
|
|
19
22
|
import kotlinx.coroutines.withContext
|
|
20
23
|
import kotlin.coroutines.coroutineContext
|
|
21
24
|
|
|
22
|
-
class
|
|
25
|
+
class MapMarkerBuilder(
|
|
23
26
|
private val scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default),
|
|
24
27
|
) {
|
|
25
28
|
private val iconCache =
|
|
@@ -34,7 +37,7 @@ class MarkerBuilder(
|
|
|
34
37
|
|
|
35
38
|
fun build(
|
|
36
39
|
m: RNMarker,
|
|
37
|
-
icon: BitmapDescriptor
|
|
40
|
+
icon: BitmapDescriptor?,
|
|
38
41
|
): MarkerOptions =
|
|
39
42
|
MarkerOptions().apply {
|
|
40
43
|
position(LatLng(m.coordinate.latitude, m.coordinate.longitude))
|
|
@@ -43,13 +46,39 @@ class MarkerBuilder(
|
|
|
43
46
|
m.zIndex?.let { zIndex(it.toFloat()) }
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
fun update(
|
|
50
|
+
marker: Marker,
|
|
51
|
+
prev: RNMarker,
|
|
52
|
+
next: RNMarker,
|
|
53
|
+
) {
|
|
54
|
+
marker.position =
|
|
55
|
+
LatLng(
|
|
56
|
+
next.coordinate.latitude,
|
|
57
|
+
next.coordinate.longitude,
|
|
58
|
+
)
|
|
59
|
+
marker.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
60
|
+
|
|
61
|
+
if (!prev.markerStyleEquals(next)) {
|
|
62
|
+
buildIconAsync(marker.id, next) { icon ->
|
|
63
|
+
marker.setIcon(icon)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
marker.setAnchor(
|
|
67
|
+
(next.anchor?.x ?: 0.5).toFloat(),
|
|
68
|
+
(next.anchor?.y ?: 0.5).toFloat(),
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
46
72
|
fun buildIconAsync(
|
|
47
73
|
id: String,
|
|
48
74
|
m: RNMarker,
|
|
49
|
-
onReady: (BitmapDescriptor) -> Unit,
|
|
75
|
+
onReady: (BitmapDescriptor?) -> Unit,
|
|
50
76
|
) {
|
|
51
77
|
jobsById[id]?.cancel()
|
|
52
|
-
|
|
78
|
+
if (m.iconSvg == null) {
|
|
79
|
+
onReady(null)
|
|
80
|
+
return
|
|
81
|
+
}
|
|
53
82
|
val key = m.styleHash()
|
|
54
83
|
iconCache.get(key)?.let { cached ->
|
|
55
84
|
onReady(cached)
|
|
@@ -98,17 +127,28 @@ class MarkerBuilder(
|
|
|
98
127
|
|
|
99
128
|
private suspend fun renderBitmap(m: RNMarker): Bitmap? {
|
|
100
129
|
var bmp: Bitmap? = null
|
|
130
|
+
if (m.iconSvg == null) {
|
|
131
|
+
return null
|
|
132
|
+
}
|
|
101
133
|
try {
|
|
102
134
|
coroutineContext.ensureActive()
|
|
103
|
-
val svg = SVG.getFromString(m.iconSvg)
|
|
135
|
+
val svg = SVG.getFromString(m.iconSvg.svgString)
|
|
104
136
|
|
|
105
137
|
coroutineContext.ensureActive()
|
|
106
|
-
svg.setDocumentWidth(m.width.dpToPx())
|
|
107
|
-
svg.setDocumentHeight(m.height.dpToPx())
|
|
138
|
+
svg.setDocumentWidth(m.iconSvg.width.dpToPx())
|
|
139
|
+
svg.setDocumentHeight(m.iconSvg.height.dpToPx())
|
|
108
140
|
|
|
109
141
|
coroutineContext.ensureActive()
|
|
110
142
|
bmp =
|
|
111
|
-
createBitmap(
|
|
143
|
+
createBitmap(
|
|
144
|
+
m.iconSvg.width
|
|
145
|
+
.dpToPx()
|
|
146
|
+
.toInt(),
|
|
147
|
+
m.iconSvg.height
|
|
148
|
+
.dpToPx()
|
|
149
|
+
.toInt(),
|
|
150
|
+
Bitmap.Config.ARGB_8888,
|
|
151
|
+
)
|
|
112
152
|
|
|
113
153
|
coroutineContext.ensureActive()
|
|
114
154
|
val canvas = Canvas(bmp)
|
|
@@ -125,22 +165,3 @@ class MarkerBuilder(
|
|
|
125
165
|
}
|
|
126
166
|
}
|
|
127
167
|
}
|
|
128
|
-
|
|
129
|
-
fun RNMarker.markerEquals(b: RNMarker): Boolean =
|
|
130
|
-
id == b.id &&
|
|
131
|
-
zIndex == b.zIndex &&
|
|
132
|
-
coordinate == b.coordinate &&
|
|
133
|
-
anchor == b.anchor &&
|
|
134
|
-
markerStyleEquals(b)
|
|
135
|
-
|
|
136
|
-
fun RNMarker.markerStyleEquals(b: RNMarker): Boolean =
|
|
137
|
-
width == b.width &&
|
|
138
|
-
height == b.height &&
|
|
139
|
-
iconSvg == b.iconSvg
|
|
140
|
-
|
|
141
|
-
fun RNMarker.styleHash(): Int =
|
|
142
|
-
arrayOf<Any?>(
|
|
143
|
-
width,
|
|
144
|
-
height,
|
|
145
|
-
iconSvg,
|
|
146
|
-
).contentHashCode()
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
package com.rngooglemapsplus
|
|
2
2
|
|
|
3
|
+
import android.graphics.Color
|
|
3
4
|
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
5
|
+
import com.google.android.gms.maps.model.LatLng
|
|
6
|
+
import com.google.android.gms.maps.model.Polygon
|
|
4
7
|
import com.google.android.gms.maps.model.PolygonOptions
|
|
5
8
|
import com.rngooglemapsplus.extensions.toColor
|
|
6
9
|
|
|
7
10
|
class MapPolygonBuilder {
|
|
8
|
-
fun
|
|
11
|
+
fun build(poly: RNPolygon): PolygonOptions =
|
|
9
12
|
PolygonOptions().apply {
|
|
10
13
|
poly.coordinates.forEach { pt ->
|
|
11
14
|
add(
|
|
@@ -19,4 +22,18 @@ class MapPolygonBuilder {
|
|
|
19
22
|
poly.pressable?.let { clickable(it) }
|
|
20
23
|
poly.zIndex?.let { zIndex(it.toFloat()) }
|
|
21
24
|
}
|
|
25
|
+
|
|
26
|
+
fun update(
|
|
27
|
+
gmsPoly: Polygon,
|
|
28
|
+
next: RNPolygon,
|
|
29
|
+
) {
|
|
30
|
+
gmsPoly.points =
|
|
31
|
+
next.coordinates.map {
|
|
32
|
+
LatLng(it.latitude, it.longitude)
|
|
33
|
+
}
|
|
34
|
+
gmsPoly.fillColor = next.fillColor?.toColor() ?: Color.TRANSPARENT
|
|
35
|
+
gmsPoly.strokeColor = next.strokeColor?.toColor() ?: Color.BLACK
|
|
36
|
+
gmsPoly.strokeWidth = next.strokeWidth?.dpToPx() ?: 1f
|
|
37
|
+
gmsPoly.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
38
|
+
}
|
|
22
39
|
}
|
|
@@ -1,40 +1,57 @@
|
|
|
1
1
|
package com.rngooglemapsplus
|
|
2
2
|
|
|
3
|
+
import android.graphics.Color
|
|
3
4
|
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
4
5
|
import com.google.android.gms.maps.model.ButtCap
|
|
5
6
|
import com.google.android.gms.maps.model.Cap
|
|
6
7
|
import com.google.android.gms.maps.model.JointType
|
|
8
|
+
import com.google.android.gms.maps.model.LatLng
|
|
9
|
+
import com.google.android.gms.maps.model.Polyline
|
|
7
10
|
import com.google.android.gms.maps.model.PolylineOptions
|
|
8
11
|
import com.google.android.gms.maps.model.RoundCap
|
|
9
12
|
import com.google.android.gms.maps.model.SquareCap
|
|
10
13
|
import com.rngooglemapsplus.extensions.toColor
|
|
11
14
|
|
|
12
15
|
class MapPolylineBuilder {
|
|
13
|
-
fun
|
|
16
|
+
fun build(pl: RNPolyline): PolylineOptions =
|
|
14
17
|
PolylineOptions().apply {
|
|
15
18
|
pl.coordinates.forEach { pt ->
|
|
16
|
-
add(
|
|
17
|
-
com.google.android.gms.maps.model
|
|
18
|
-
.LatLng(pt.latitude, pt.longitude),
|
|
19
|
-
)
|
|
19
|
+
add(LatLng(pt.latitude, pt.longitude))
|
|
20
20
|
}
|
|
21
21
|
pl.width?.let { width(it.dpToPx()) }
|
|
22
|
-
pl.lineCap?.let {
|
|
23
|
-
|
|
22
|
+
pl.lineCap?.let {
|
|
23
|
+
startCap(mapLineCap(it))
|
|
24
|
+
endCap(mapLineCap(it))
|
|
25
|
+
}
|
|
24
26
|
pl.lineJoin?.let { jointType(mapLineJoin(it)) }
|
|
25
27
|
pl.color?.let { color(it.toColor()) }
|
|
26
28
|
pl.pressable?.let { clickable(it) }
|
|
27
29
|
pl.zIndex?.let { zIndex(it.toFloat()) }
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
fun
|
|
32
|
+
fun update(
|
|
33
|
+
polyline: Polyline,
|
|
34
|
+
next: RNPolyline,
|
|
35
|
+
) {
|
|
36
|
+
polyline.points = next.coordinates.map { LatLng(it.latitude, it.longitude) }
|
|
37
|
+
|
|
38
|
+
polyline.width = next.width?.dpToPx() ?: 1f
|
|
39
|
+
val cap = mapLineCap(next.lineCap ?: RNLineCapType.BUTT)
|
|
40
|
+
polyline.startCap = cap
|
|
41
|
+
polyline.endCap = cap
|
|
42
|
+
polyline.jointType = mapLineJoin(next.lineJoin ?: RNLineJoinType.MITER)
|
|
43
|
+
polyline.color = next.color?.toColor() ?: Color.BLACK
|
|
44
|
+
polyline.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private fun mapLineCap(type: RNLineCapType?): Cap =
|
|
31
48
|
when (type) {
|
|
32
49
|
RNLineCapType.ROUND -> RoundCap()
|
|
33
50
|
RNLineCapType.SQUARE -> SquareCap()
|
|
34
51
|
else -> ButtCap()
|
|
35
52
|
}
|
|
36
53
|
|
|
37
|
-
fun mapLineJoin(type: RNLineJoinType?): Int =
|
|
54
|
+
private fun mapLineJoin(type: RNLineJoinType?): Int =
|
|
38
55
|
when (type) {
|
|
39
56
|
RNLineJoinType.ROUND -> JointType.ROUND
|
|
40
57
|
RNLineJoinType.BEVEL -> JointType.BEVEL
|