react-native-google-maps-plus 1.3.0-dev.2 → 1.3.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/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +86 -5
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +0 -1
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +38 -4
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNLatLngBoundsExtension.kt +17 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNSize.kt +7 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNSnapshotFormat.kt +16 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNSnapshotResultType.kt +9 -0
- package/ios/GoogleMapViewImpl.swift +261 -131
- package/ios/RNGoogleMapsPlusView.swift +72 -27
- package/ios/extensions/RNLatLngBounds+Extension.swift +16 -0
- package/ios/extensions/RNSize+Extension.swift +7 -0
- package/ios/extensions/RNSnapshotFormat+Extension.swift +28 -0
- package/ios/extensions/RNSnapshotResultType+Extension.swift +12 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts +6 -3
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +13 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +51 -7
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +5 -2
- package/nitrogen/generated/android/c++/JRNLatLngBounds.hpp +58 -0
- package/nitrogen/generated/android/c++/JRNSize.hpp +57 -0
- package/nitrogen/generated/android/c++/JRNSnapshotFormat.hpp +62 -0
- package/nitrogen/generated/android/c++/JRNSnapshotOptions.hpp +71 -0
- package/nitrogen/generated/android/c++/JRNSnapshotResultType.hpp +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +14 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLatLngBounds.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNSize.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNSnapshotFormat.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNSnapshotOptions.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNSnapshotResultType.kt +21 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +57 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +15 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +40 -5
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +5 -2
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +58 -4
- package/nitrogen/generated/ios/swift/RNLatLngBounds.swift +46 -0
- package/nitrogen/generated/ios/swift/RNSize.swift +46 -0
- package/nitrogen/generated/ios/swift/RNSnapshotFormat.swift +44 -0
- package/nitrogen/generated/ios/swift/RNSnapshotOptions.swift +87 -0
- package/nitrogen/generated/ios/swift/RNSnapshotResultType.swift +40 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +3 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +12 -3
- package/nitrogen/generated/shared/c++/RNLatLngBounds.hpp +72 -0
- package/nitrogen/generated/shared/c++/RNSize.hpp +71 -0
- package/nitrogen/generated/shared/c++/RNSnapshotFormat.hpp +80 -0
- package/nitrogen/generated/shared/c++/RNSnapshotOptions.hpp +87 -0
- package/nitrogen/generated/shared/c++/RNSnapshotResultType.hpp +76 -0
- package/package.json +1 -1
- package/src/RNGoogleMapsPlusView.nitro.ts +15 -2
- package/src/types.ts +24 -2
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
package com.rngooglemapsplus
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
|
+
import android.graphics.Bitmap
|
|
4
5
|
import android.location.Location
|
|
6
|
+
import android.util.Base64
|
|
7
|
+
import android.util.Size
|
|
5
8
|
import android.widget.FrameLayout
|
|
9
|
+
import androidx.core.graphics.scale
|
|
6
10
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
7
11
|
import com.facebook.react.bridge.UiThreadUtil
|
|
8
12
|
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
@@ -29,11 +33,15 @@ import com.google.android.gms.maps.model.PolylineOptions
|
|
|
29
33
|
import com.google.android.gms.maps.model.TileOverlay
|
|
30
34
|
import com.google.android.gms.maps.model.TileOverlayOptions
|
|
31
35
|
import com.google.maps.android.data.kml.KmlLayer
|
|
36
|
+
import com.margelo.nitro.core.Promise
|
|
32
37
|
import com.rngooglemapsplus.extensions.toGooglePriority
|
|
33
38
|
import com.rngooglemapsplus.extensions.toLocationErrorCode
|
|
34
39
|
import com.rngooglemapsplus.extensions.toRNIndoorBuilding
|
|
35
40
|
import com.rngooglemapsplus.extensions.toRNIndoorLevel
|
|
36
41
|
import java.io.ByteArrayInputStream
|
|
42
|
+
import java.io.ByteArrayOutputStream
|
|
43
|
+
import java.io.File
|
|
44
|
+
import java.io.FileOutputStream
|
|
37
45
|
import java.nio.charset.StandardCharsets
|
|
38
46
|
|
|
39
47
|
class GoogleMapsViewImpl(
|
|
@@ -188,6 +196,8 @@ class GoogleMapsViewImpl(
|
|
|
188
196
|
if (cameraPosition == lastSubmittedCameraPosition) {
|
|
189
197
|
return
|
|
190
198
|
}
|
|
199
|
+
lastSubmittedCameraPosition = cameraPosition
|
|
200
|
+
|
|
191
201
|
val isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason
|
|
192
202
|
|
|
193
203
|
val latDelta = bounds.northeast.latitude - bounds.southwest.latitude
|
|
@@ -207,7 +217,6 @@ class GoogleMapsViewImpl(
|
|
|
207
217
|
),
|
|
208
218
|
isGesture,
|
|
209
219
|
)
|
|
210
|
-
lastSubmittedCameraPosition = cameraPosition
|
|
211
220
|
}
|
|
212
221
|
|
|
213
222
|
override fun onCameraIdle() {
|
|
@@ -503,7 +512,7 @@ class GoogleMapsViewImpl(
|
|
|
503
512
|
fun setCamera(
|
|
504
513
|
cameraPosition: CameraPosition,
|
|
505
514
|
animated: Boolean,
|
|
506
|
-
|
|
515
|
+
durationMs: Int,
|
|
507
516
|
) {
|
|
508
517
|
onUi {
|
|
509
518
|
val current = googleMap?.cameraPosition
|
|
@@ -514,7 +523,7 @@ class GoogleMapsViewImpl(
|
|
|
514
523
|
val update = CameraUpdateFactory.newCameraPosition(cameraPosition)
|
|
515
524
|
|
|
516
525
|
if (animated) {
|
|
517
|
-
googleMap?.animateCamera(update,
|
|
526
|
+
googleMap?.animateCamera(update, durationMs, null)
|
|
518
527
|
} else {
|
|
519
528
|
googleMap?.moveCamera(update)
|
|
520
529
|
}
|
|
@@ -525,7 +534,7 @@ class GoogleMapsViewImpl(
|
|
|
525
534
|
coordinates: Array<RNLatLng>,
|
|
526
535
|
padding: RNMapPadding,
|
|
527
536
|
animated: Boolean,
|
|
528
|
-
|
|
537
|
+
durationMs: Int,
|
|
529
538
|
) {
|
|
530
539
|
if (coordinates.isEmpty()) {
|
|
531
540
|
return
|
|
@@ -583,13 +592,85 @@ class GoogleMapsViewImpl(
|
|
|
583
592
|
0,
|
|
584
593
|
)
|
|
585
594
|
if (animated) {
|
|
586
|
-
googleMap?.animateCamera(update,
|
|
595
|
+
googleMap?.animateCamera(update, durationMs, null)
|
|
587
596
|
} else {
|
|
588
597
|
googleMap?.moveCamera(update)
|
|
589
598
|
}
|
|
590
599
|
}
|
|
591
600
|
}
|
|
592
601
|
|
|
602
|
+
fun setCameraBounds(bounds: LatLngBounds?) {
|
|
603
|
+
onUi {
|
|
604
|
+
googleMap?.setLatLngBoundsForCameraTarget(bounds)
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
fun animateToBounds(
|
|
609
|
+
bounds: LatLngBounds,
|
|
610
|
+
padding: Int,
|
|
611
|
+
durationMs: Int,
|
|
612
|
+
lockBounds: Boolean,
|
|
613
|
+
) {
|
|
614
|
+
onUi {
|
|
615
|
+
if (lockBounds) {
|
|
616
|
+
googleMap?.setLatLngBoundsForCameraTarget(bounds)
|
|
617
|
+
}
|
|
618
|
+
val update =
|
|
619
|
+
CameraUpdateFactory.newLatLngBounds(
|
|
620
|
+
bounds,
|
|
621
|
+
padding,
|
|
622
|
+
)
|
|
623
|
+
googleMap?.animateCamera(update, durationMs, null)
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
fun snapshot(
|
|
628
|
+
size: Size?,
|
|
629
|
+
format: String,
|
|
630
|
+
compressFormat: Bitmap.CompressFormat,
|
|
631
|
+
quality: Double,
|
|
632
|
+
resultIsFile: Boolean,
|
|
633
|
+
): Promise<String?> {
|
|
634
|
+
val promise = Promise<String?>()
|
|
635
|
+
onUi {
|
|
636
|
+
googleMap?.snapshot { bitmap ->
|
|
637
|
+
try {
|
|
638
|
+
if (bitmap == null) {
|
|
639
|
+
promise.resolve(null)
|
|
640
|
+
return@snapshot
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
val scaledBitmap =
|
|
644
|
+
size?.let {
|
|
645
|
+
bitmap.scale(it.width, it.height)
|
|
646
|
+
} ?: bitmap
|
|
647
|
+
|
|
648
|
+
val output = ByteArrayOutputStream()
|
|
649
|
+
scaledBitmap.compress(compressFormat, (quality * 100).toInt().coerceIn(0, 100), output)
|
|
650
|
+
val bytes = output.toByteArray()
|
|
651
|
+
|
|
652
|
+
if (resultIsFile) {
|
|
653
|
+
val file = File(context.cacheDir, "map_snapshot_${System.currentTimeMillis()}.$format")
|
|
654
|
+
FileOutputStream(file).use { it.write(bytes) }
|
|
655
|
+
promise.resolve(file.absolutePath)
|
|
656
|
+
} else {
|
|
657
|
+
val base64 = Base64.encodeToString(bytes, Base64.NO_WRAP)
|
|
658
|
+
promise.resolve("data:image/$format;base64,$base64")
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
if (scaledBitmap != bitmap) {
|
|
662
|
+
scaledBitmap.recycle()
|
|
663
|
+
}
|
|
664
|
+
bitmap.recycle()
|
|
665
|
+
} catch (e: Exception) {
|
|
666
|
+
promise.resolve(null)
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
return promise
|
|
672
|
+
}
|
|
673
|
+
|
|
593
674
|
fun addMarker(
|
|
594
675
|
id: String,
|
|
595
676
|
opts: MarkerOptions,
|
|
@@ -6,11 +6,16 @@ import com.facebook.react.uimanager.ThemedReactContext
|
|
|
6
6
|
import com.google.android.gms.maps.model.MapStyleOptions
|
|
7
7
|
import com.margelo.nitro.core.Promise
|
|
8
8
|
import com.rngooglemapsplus.extensions.circleEquals
|
|
9
|
+
import com.rngooglemapsplus.extensions.isFileResult
|
|
9
10
|
import com.rngooglemapsplus.extensions.markerEquals
|
|
10
11
|
import com.rngooglemapsplus.extensions.polygonEquals
|
|
11
12
|
import com.rngooglemapsplus.extensions.polylineEquals
|
|
12
13
|
import com.rngooglemapsplus.extensions.toCameraPosition
|
|
14
|
+
import com.rngooglemapsplus.extensions.toCompressFormat
|
|
15
|
+
import com.rngooglemapsplus.extensions.toFileExtension
|
|
16
|
+
import com.rngooglemapsplus.extensions.toLatLngBounds
|
|
13
17
|
import com.rngooglemapsplus.extensions.toMapColorScheme
|
|
18
|
+
import com.rngooglemapsplus.extensions.toSize
|
|
14
19
|
|
|
15
20
|
@DoNotStrip
|
|
16
21
|
class RNGoogleMapsPlusView(
|
|
@@ -343,25 +348,54 @@ class RNGoogleMapsPlusView(
|
|
|
343
348
|
override fun setCamera(
|
|
344
349
|
camera: RNCamera,
|
|
345
350
|
animated: Boolean?,
|
|
346
|
-
|
|
351
|
+
durationMs: Double?,
|
|
347
352
|
) {
|
|
348
|
-
view.setCamera(camera.toCameraPosition(), animated == true,
|
|
353
|
+
view.setCamera(camera.toCameraPosition(), animated == true, durationMs?.toInt() ?: 3000)
|
|
349
354
|
}
|
|
350
355
|
|
|
351
356
|
override fun setCameraToCoordinates(
|
|
352
357
|
coordinates: Array<RNLatLng>,
|
|
353
358
|
padding: RNMapPadding?,
|
|
354
359
|
animated: Boolean?,
|
|
355
|
-
|
|
360
|
+
durationMs: Double?,
|
|
356
361
|
) {
|
|
357
362
|
view.setCameraToCoordinates(
|
|
358
363
|
coordinates,
|
|
359
364
|
padding = padding ?: RNMapPadding(0.0, 0.0, 0.0, 0.0),
|
|
360
365
|
animated == true,
|
|
361
|
-
|
|
366
|
+
durationMs?.toInt() ?: 3000,
|
|
362
367
|
)
|
|
363
368
|
}
|
|
364
369
|
|
|
370
|
+
override fun setCameraBounds(bounds: RNLatLngBounds?) {
|
|
371
|
+
view.setCameraBounds(
|
|
372
|
+
bounds?.toLatLngBounds(),
|
|
373
|
+
)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
override fun animateToBounds(
|
|
377
|
+
bounds: RNLatLngBounds,
|
|
378
|
+
padding: Double?,
|
|
379
|
+
durationMs: Double?,
|
|
380
|
+
lockBounds: Boolean?,
|
|
381
|
+
) {
|
|
382
|
+
view.animateToBounds(
|
|
383
|
+
bounds.toLatLngBounds(),
|
|
384
|
+
padding = padding?.toInt() ?: 0,
|
|
385
|
+
durationMs?.toInt() ?: 3000,
|
|
386
|
+
lockBounds = false,
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
override fun snapshot(options: RNSnapshotOptions): Promise<String?> =
|
|
391
|
+
view.snapshot(
|
|
392
|
+
size = options.size.toSize(),
|
|
393
|
+
format = options.format.toFileExtension(),
|
|
394
|
+
compressFormat = options.format.toCompressFormat(),
|
|
395
|
+
quality = options.quality,
|
|
396
|
+
resultIsFile = options.resultType.isFileResult(),
|
|
397
|
+
)
|
|
398
|
+
|
|
365
399
|
override fun showLocationDialog() {
|
|
366
400
|
locationHandler.showLocationDialog()
|
|
367
401
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.google.android.gms.maps.model.LatLng
|
|
4
|
+
import com.google.android.gms.maps.model.LatLngBounds
|
|
5
|
+
import com.rngooglemapsplus.RNLatLngBounds
|
|
6
|
+
|
|
7
|
+
fun RNLatLngBounds.toLatLngBounds(): LatLngBounds =
|
|
8
|
+
LatLngBounds(
|
|
9
|
+
LatLng(
|
|
10
|
+
southWest.latitude,
|
|
11
|
+
southWest.longitude,
|
|
12
|
+
),
|
|
13
|
+
LatLng(
|
|
14
|
+
northEast.latitude,
|
|
15
|
+
northEast.longitude,
|
|
16
|
+
),
|
|
17
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import android.graphics.Bitmap
|
|
4
|
+
import com.rngooglemapsplus.RNSnapshotFormat
|
|
5
|
+
|
|
6
|
+
fun RNSnapshotFormat?.toCompressFormat(): Bitmap.CompressFormat =
|
|
7
|
+
when (this) {
|
|
8
|
+
RNSnapshotFormat.JPG, RNSnapshotFormat.JPEG -> Bitmap.CompressFormat.JPEG
|
|
9
|
+
RNSnapshotFormat.PNG, null -> Bitmap.CompressFormat.PNG
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
fun RNSnapshotFormat?.toFileExtension(): String =
|
|
13
|
+
when (this) {
|
|
14
|
+
RNSnapshotFormat.JPG, RNSnapshotFormat.JPEG -> "jpg"
|
|
15
|
+
RNSnapshotFormat.PNG, null -> "png"
|
|
16
|
+
}
|