react-native-google-maps-plus 1.1.0-dev.2 → 1.1.0-dev.4
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 +7 -5
- package/RNGoogleMapsPlus.podspec +2 -1
- package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +91 -102
- 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/MapHeatmapBuilder.kt +31 -0
- package/android/src/main/java/com/rngooglemapsplus/MapMarkerBuilder.kt +25 -0
- 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 +61 -71
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNHeatmapPointExtension.kt +9 -0
- package/ios/GoogleMapViewImpl.swift +129 -213
- package/ios/LocationHandler.swift +2 -10
- package/ios/MapCircleBuilder.swift +23 -8
- package/ios/MapHeatmapBuilder.swift +27 -0
- package/ios/MapHelper.swift +6 -4
- package/ios/MapMarkerBuilder.swift +39 -41
- package/ios/MapPolygonBuilder.swift +25 -7
- package/ios/MapPolylineBuilder.swift +27 -11
- package/ios/RNGoogleMapsPlusView.swift +31 -14
- package/ios/extensions/RNCircle+Extension.swift +0 -13
- package/ios/extensions/RNHeatmap+Extension.swift +16 -0
- 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 +3 -3
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +24 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +48 -15
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +4 -4
- package/nitrogen/generated/android/c++/JRNCircle.hpp +4 -4
- package/nitrogen/generated/android/c++/JRNHeatmap.hpp +100 -0
- package/nitrogen/generated/android/c++/JRNHeatmapGradient.hpp +89 -0
- package/nitrogen/generated/android/c++/JRNHeatmapPoint.hpp +61 -0
- package/nitrogen/generated/android/c++/JRNMapZoomConfig.hpp +57 -0
- package/nitrogen/generated/android/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +6 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +7 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNCircle.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNHeatmap.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNHeatmapGradient.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNHeatmapPoint.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapZoomConfig.kt +32 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +101 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +12 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +23 -11
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +9 -9
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +2 -2
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +39 -19
- package/nitrogen/generated/ios/swift/RNCircle.swift +5 -17
- package/nitrogen/generated/ios/swift/RNHeatmap.swift +180 -0
- package/nitrogen/generated/ios/swift/RNHeatmapGradient.swift +81 -0
- package/nitrogen/generated/ios/swift/RNHeatmapPoint.swift +57 -0
- package/nitrogen/generated/ios/swift/RNMapZoomConfig.swift +70 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +4 -4
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +10 -4
- package/nitrogen/generated/shared/c++/RNCircle.hpp +5 -5
- package/nitrogen/generated/shared/c++/RNHeatmap.hpp +98 -0
- package/nitrogen/generated/shared/c++/RNHeatmapGradient.hpp +76 -0
- package/nitrogen/generated/shared/c++/RNHeatmapPoint.hpp +75 -0
- package/nitrogen/generated/shared/c++/RNMapZoomConfig.hpp +71 -0
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +19 -19
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +4 -2
- package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +2 -2
- package/package.json +12 -12
- package/src/RNGoogleMapsPlusView.nitro.ts +4 -2
- package/src/types.ts +28 -1
package/README.md
CHANGED
|
@@ -22,13 +22,15 @@ React-native wrapper for android & IOS google maps sdk
|
|
|
22
22
|
yarn add react-native-google-maps-plus react-native-nitro-modules
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
Dependencies
|
|
25
|
+
# Dependencies
|
|
26
26
|
|
|
27
|
-
This package builds on native SVG rendering
|
|
27
|
+
This package builds on native libraries for SVG rendering and Google Maps integration:
|
|
28
28
|
|
|
29
|
-
iOS
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
- **iOS**: [SVGKit](https://github.com/SVGKit/SVGKit)
|
|
30
|
+
- **Android**: [AndroidSVG](https://bigbadaboom.github.io/androidsvg/)
|
|
31
|
+
- **iOS Maps SDK**: [Google Maps SDK for iOS](https://developers.google.com/maps/documentation/ios-sdk)
|
|
32
|
+
- **Android Maps SDK**: [Google Maps SDK for Android](https://developers.google.com/maps/documentation/android-sdk)
|
|
33
|
+
- **Maps Utility Libraries**: [Google Maps Utils for iOS](https://developers.google.com/maps/documentation/ios-sdk/utility) and [Google Maps Utils for Android](https://developers.google.com/maps/documentation/android-sdk/utility)
|
|
32
34
|
|
|
33
35
|
These are automatically linked when you install the package, but you may need to clean/rebuild your native projects after first install.
|
|
34
36
|
|
package/RNGoogleMapsPlus.podspec
CHANGED
|
@@ -26,7 +26,8 @@ Pod::Spec.new do |s|
|
|
|
26
26
|
s.dependency 'React-jsi'
|
|
27
27
|
s.dependency 'React-callinvoker'
|
|
28
28
|
|
|
29
|
-
s.dependency 'GoogleMaps', '10.
|
|
29
|
+
s.dependency 'GoogleMaps', '10.4.0'
|
|
30
|
+
s.dependency 'Google-Maps-iOS-Utils', '6.1.3'
|
|
30
31
|
s.dependency 'SVGKit', '3.0.0'
|
|
31
32
|
|
|
32
33
|
load 'nitrogen/generated/ios/RNGoogleMapsPlus+autolinking.rb'
|
|
@@ -25,6 +25,8 @@ import com.google.android.gms.maps.model.Polygon
|
|
|
25
25
|
import com.google.android.gms.maps.model.PolygonOptions
|
|
26
26
|
import com.google.android.gms.maps.model.Polyline
|
|
27
27
|
import com.google.android.gms.maps.model.PolylineOptions
|
|
28
|
+
import com.google.android.gms.maps.model.TileOverlay
|
|
29
|
+
import com.google.android.gms.maps.model.TileOverlayOptions
|
|
28
30
|
import com.rngooglemapsplus.extensions.toGooglePriority
|
|
29
31
|
import com.rngooglemapsplus.extensions.toLocationErrorCode
|
|
30
32
|
|
|
@@ -52,11 +54,13 @@ class GoogleMapsViewImpl(
|
|
|
52
54
|
private val pendingPolylines = mutableListOf<Pair<String, PolylineOptions>>()
|
|
53
55
|
private val pendingPolygons = mutableListOf<Pair<String, PolygonOptions>>()
|
|
54
56
|
private val pendingCircles = mutableListOf<Pair<String, CircleOptions>>()
|
|
57
|
+
private val pendingHeatmaps = mutableListOf<Pair<String, TileOverlayOptions>>()
|
|
55
58
|
|
|
56
59
|
private val markersById = mutableMapOf<String, Marker>()
|
|
57
60
|
private val polylinesById = mutableMapOf<String, Polyline>()
|
|
58
61
|
private val polygonsById = mutableMapOf<String, Polygon>()
|
|
59
62
|
private val circlesById = mutableMapOf<String, Circle>()
|
|
63
|
+
private val heatmapsById = mutableMapOf<String, TileOverlay>()
|
|
60
64
|
|
|
61
65
|
private var cameraMoveReason = -1
|
|
62
66
|
private var lastSubmittedLocation: Location? = null
|
|
@@ -293,11 +297,9 @@ class GoogleMapsViewImpl(
|
|
|
293
297
|
userInterfaceStyle?.let {
|
|
294
298
|
googleMap?.mapColorScheme = it
|
|
295
299
|
}
|
|
296
|
-
|
|
297
|
-
googleMap?.setMinZoomPreference(it.toFloat())
|
|
298
|
-
|
|
299
|
-
maxZoomLevel?.let {
|
|
300
|
-
googleMap?.setMaxZoomPreference(it.toFloat())
|
|
300
|
+
mapZoomConfig?.let {
|
|
301
|
+
googleMap?.setMinZoomPreference(it.min?.toFloat() ?: 2.0f)
|
|
302
|
+
googleMap?.setMaxZoomPreference(it.max?.toFloat() ?: 21.0f)
|
|
301
303
|
}
|
|
302
304
|
}
|
|
303
305
|
|
|
@@ -334,62 +336,47 @@ class GoogleMapsViewImpl(
|
|
|
334
336
|
}
|
|
335
337
|
pendingCircles.clear()
|
|
336
338
|
}
|
|
339
|
+
|
|
340
|
+
if (pendingHeatmaps.isNotEmpty()) {
|
|
341
|
+
pendingHeatmaps.forEach { (id, opts) ->
|
|
342
|
+
internalAddHeatmap(id, opts)
|
|
343
|
+
}
|
|
344
|
+
pendingHeatmaps.clear()
|
|
345
|
+
}
|
|
337
346
|
}
|
|
338
347
|
|
|
339
348
|
var uiSettings: RNMapUiSettings? = null
|
|
340
349
|
set(value) {
|
|
341
350
|
field = value
|
|
342
351
|
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
|
-
}
|
|
352
|
+
googleMap?.uiSettings?.apply {
|
|
353
|
+
setAllGesturesEnabled(value?.allGesturesEnabled ?: true)
|
|
354
|
+
isCompassEnabled = value?.compassEnabled ?: false
|
|
355
|
+
isIndoorLevelPickerEnabled = value?.indoorLevelPickerEnabled ?: false
|
|
356
|
+
isMapToolbarEnabled = value?.mapToolbarEnabled ?: false
|
|
357
|
+
|
|
358
|
+
val myLocationEnabled = value?.myLocationButtonEnabled ?: false
|
|
359
|
+
googleMap?.setLocationSource(if (myLocationEnabled) locationHandler else null)
|
|
360
|
+
isMyLocationButtonEnabled = myLocationEnabled
|
|
361
|
+
|
|
362
|
+
isRotateGesturesEnabled = value?.rotateEnabled ?: true
|
|
363
|
+
isScrollGesturesEnabled = value?.scrollEnabled ?: true
|
|
364
|
+
isScrollGesturesEnabledDuringRotateOrZoom =
|
|
365
|
+
value?.scrollDuringRotateOrZoomEnabled ?: true
|
|
366
|
+
isTiltGesturesEnabled = value?.tiltEnabled ?: true
|
|
367
|
+
isZoomControlsEnabled = value?.zoomControlsEnabled ?: false
|
|
368
|
+
isZoomGesturesEnabled = value?.zoomGesturesEnabled ?: false
|
|
362
369
|
}
|
|
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
370
|
}
|
|
380
371
|
}
|
|
381
372
|
|
|
382
373
|
@SuppressLint("MissingPermission")
|
|
383
374
|
var myLocationEnabled: Boolean? = null
|
|
384
375
|
set(value) {
|
|
376
|
+
field = value
|
|
385
377
|
onUi {
|
|
386
378
|
try {
|
|
387
|
-
|
|
388
|
-
googleMap?.isMyLocationEnabled = it
|
|
389
|
-
}
|
|
390
|
-
?: run {
|
|
391
|
-
googleMap?.isMyLocationEnabled = false
|
|
392
|
-
}
|
|
379
|
+
googleMap?.isMyLocationEnabled = value ?: false
|
|
393
380
|
} catch (se: SecurityException) {
|
|
394
381
|
onLocationError?.invoke(RNLocationErrorCode.PERMISSION_DENIED)
|
|
395
382
|
} catch (ex: Exception) {
|
|
@@ -403,12 +390,7 @@ class GoogleMapsViewImpl(
|
|
|
403
390
|
set(value) {
|
|
404
391
|
field = value
|
|
405
392
|
onUi {
|
|
406
|
-
|
|
407
|
-
googleMap?.isBuildingsEnabled = it
|
|
408
|
-
}
|
|
409
|
-
?: run {
|
|
410
|
-
googleMap?.isBuildingsEnabled = false
|
|
411
|
-
}
|
|
393
|
+
googleMap?.isBuildingsEnabled = value ?: false
|
|
412
394
|
}
|
|
413
395
|
}
|
|
414
396
|
|
|
@@ -416,11 +398,7 @@ class GoogleMapsViewImpl(
|
|
|
416
398
|
set(value) {
|
|
417
399
|
field = value
|
|
418
400
|
onUi {
|
|
419
|
-
|
|
420
|
-
googleMap?.isTrafficEnabled = it
|
|
421
|
-
} ?: run {
|
|
422
|
-
googleMap?.isTrafficEnabled = false
|
|
423
|
-
}
|
|
401
|
+
googleMap?.isTrafficEnabled = value ?: false
|
|
424
402
|
}
|
|
425
403
|
}
|
|
426
404
|
|
|
@@ -428,12 +406,7 @@ class GoogleMapsViewImpl(
|
|
|
428
406
|
set(value) {
|
|
429
407
|
field = value
|
|
430
408
|
onUi {
|
|
431
|
-
|
|
432
|
-
googleMap?.isIndoorEnabled = it
|
|
433
|
-
}
|
|
434
|
-
?: run {
|
|
435
|
-
googleMap?.isIndoorEnabled = false
|
|
436
|
-
}
|
|
409
|
+
googleMap?.isIndoorEnabled = value ?: false
|
|
437
410
|
}
|
|
438
411
|
}
|
|
439
412
|
|
|
@@ -449,52 +422,29 @@ class GoogleMapsViewImpl(
|
|
|
449
422
|
set(value) {
|
|
450
423
|
field = value
|
|
451
424
|
onUi {
|
|
452
|
-
|
|
453
|
-
googleMap?.mapColorScheme = it
|
|
454
|
-
} ?: run {
|
|
455
|
-
googleMap?.mapColorScheme = MapColorScheme.FOLLOW_SYSTEM
|
|
456
|
-
}
|
|
425
|
+
googleMap?.mapColorScheme = value ?: MapColorScheme.FOLLOW_SYSTEM
|
|
457
426
|
}
|
|
458
427
|
}
|
|
459
428
|
|
|
460
|
-
var
|
|
429
|
+
var mapZoomConfig: RNMapZoomConfig? = null
|
|
461
430
|
set(value) {
|
|
462
431
|
field = value
|
|
463
432
|
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
|
-
}
|
|
433
|
+
googleMap?.setMinZoomPreference(value?.min?.toFloat() ?: 2.0f)
|
|
434
|
+
googleMap?.setMaxZoomPreference(value?.max?.toFloat() ?: 21.0f)
|
|
481
435
|
}
|
|
482
436
|
}
|
|
483
437
|
|
|
484
438
|
var mapPadding: RNMapPadding? = null
|
|
485
439
|
set(value) {
|
|
486
440
|
field = value
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
)
|
|
495
|
-
}
|
|
496
|
-
} ?: run {
|
|
497
|
-
googleMap?.setPadding(0, 0, 0, 0)
|
|
441
|
+
onUi {
|
|
442
|
+
googleMap?.setPadding(
|
|
443
|
+
value?.left?.dpToPx()?.toInt() ?: 0,
|
|
444
|
+
value?.top?.dpToPx()?.toInt() ?: 0,
|
|
445
|
+
value?.right?.dpToPx()?.toInt() ?: 0,
|
|
446
|
+
value?.bottom?.dpToPx()?.toInt() ?: 0,
|
|
447
|
+
)
|
|
498
448
|
}
|
|
499
449
|
}
|
|
500
450
|
|
|
@@ -502,11 +452,7 @@ class GoogleMapsViewImpl(
|
|
|
502
452
|
set(value) {
|
|
503
453
|
field = value
|
|
504
454
|
onUi {
|
|
505
|
-
|
|
506
|
-
googleMap?.mapType = it
|
|
507
|
-
} ?: run {
|
|
508
|
-
googleMap?.mapType = 1
|
|
509
|
-
}
|
|
455
|
+
googleMap?.mapType = value ?: 1
|
|
510
456
|
}
|
|
511
457
|
}
|
|
512
458
|
|
|
@@ -837,6 +783,48 @@ class GoogleMapsViewImpl(
|
|
|
837
783
|
pendingCircles.clear()
|
|
838
784
|
}
|
|
839
785
|
|
|
786
|
+
fun addHeatmap(
|
|
787
|
+
id: String,
|
|
788
|
+
opts: TileOverlayOptions,
|
|
789
|
+
) {
|
|
790
|
+
if (googleMap == null) {
|
|
791
|
+
pendingHeatmaps.add(id to opts)
|
|
792
|
+
return
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
onUi {
|
|
796
|
+
heatmapsById.remove(id)?.remove()
|
|
797
|
+
}
|
|
798
|
+
internalAddHeatmap(id, opts)
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
private fun internalAddHeatmap(
|
|
802
|
+
id: String,
|
|
803
|
+
opts: TileOverlayOptions,
|
|
804
|
+
) {
|
|
805
|
+
onUi {
|
|
806
|
+
val heatmap =
|
|
807
|
+
googleMap?.addTileOverlay(opts)
|
|
808
|
+
if (heatmap != null) {
|
|
809
|
+
heatmapsById[id] = heatmap
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
fun removeHeatmap(id: String) {
|
|
815
|
+
onUi {
|
|
816
|
+
heatmapsById.remove(id)?.remove()
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
fun clearHeatmaps() {
|
|
821
|
+
onUi {
|
|
822
|
+
heatmapsById.values.forEach { it.remove() }
|
|
823
|
+
}
|
|
824
|
+
circlesById.clear()
|
|
825
|
+
pendingHeatmaps.clear()
|
|
826
|
+
}
|
|
827
|
+
|
|
840
828
|
fun destroyInternal() {
|
|
841
829
|
onUi {
|
|
842
830
|
markerBuilder.cancelAllJobs()
|
|
@@ -844,6 +832,7 @@ class GoogleMapsViewImpl(
|
|
|
844
832
|
clearPolylines()
|
|
845
833
|
clearPolygons()
|
|
846
834
|
clearCircles()
|
|
835
|
+
clearHeatmaps()
|
|
847
836
|
locationHandler.stop()
|
|
848
837
|
googleMap?.apply {
|
|
849
838
|
setOnCameraMoveStartedListener(null)
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.rngooglemapsplus
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
4
|
+
import com.google.android.gms.maps.model.TileOverlayOptions
|
|
5
|
+
import com.google.maps.android.heatmaps.Gradient
|
|
6
|
+
import com.google.maps.android.heatmaps.HeatmapTileProvider
|
|
7
|
+
import com.rngooglemapsplus.extensions.toColor
|
|
8
|
+
import com.rngooglemapsplus.extensions.toWeightedLatLngs
|
|
9
|
+
|
|
10
|
+
class MapHeatmapBuilder {
|
|
11
|
+
fun build(heatmap: RNHeatmap): TileOverlayOptions {
|
|
12
|
+
val provider =
|
|
13
|
+
HeatmapTileProvider
|
|
14
|
+
.Builder()
|
|
15
|
+
.apply {
|
|
16
|
+
weightedData(heatmap.weightedData.toWeightedLatLngs())
|
|
17
|
+
heatmap.radius?.let { radius(it.dpToPx().toInt().coerceIn(10, 50)) }
|
|
18
|
+
heatmap.opacity?.let { opacity(it) }
|
|
19
|
+
heatmap.gradient?.let {
|
|
20
|
+
val colors = it.colors.map { c -> c.toColor() }.toIntArray()
|
|
21
|
+
val startPoints = it.startPoints.map { p -> p.toFloat() }.toFloatArray()
|
|
22
|
+
gradient(Gradient(colors, startPoints))
|
|
23
|
+
}
|
|
24
|
+
}.build()
|
|
25
|
+
|
|
26
|
+
return TileOverlayOptions().apply {
|
|
27
|
+
tileProvider(provider)
|
|
28
|
+
heatmap.zIndex?.let { zIndex(it.toFloat()) }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -9,7 +9,9 @@ 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
|
|
13
15
|
import com.rngooglemapsplus.extensions.styleHash
|
|
14
16
|
import kotlinx.coroutines.CoroutineScope
|
|
15
17
|
import kotlinx.coroutines.Dispatchers
|
|
@@ -44,6 +46,29 @@ class MapMarkerBuilder(
|
|
|
44
46
|
m.zIndex?.let { zIndex(it.toFloat()) }
|
|
45
47
|
}
|
|
46
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
|
+
|
|
47
72
|
fun buildIconAsync(
|
|
48
73
|
id: String,
|
|
49
74
|
m: RNMarker,
|
|
@@ -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
|