react-native-google-maps-plus 1.3.0-dev.1 → 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 +107 -5
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +0 -1
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +48 -4
- package/android/src/main/java/com/rngooglemapsplus/extensions/IndoorBuildingExtension.kt +33 -0
- 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 +277 -121
- package/ios/RNGoogleMapsPlusView.swift +78 -27
- package/ios/extensions/IndoorBuilding+Extension.swift +33 -0
- 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 +8 -3
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +25 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/RNGoogleMapsPlusOnLoad.cpp +4 -0
- package/nitrogen/generated/android/c++/JFunc_void_RNIndoorBuilding.hpp +81 -0
- package/nitrogen/generated/android/c++/JFunc_void_RNIndoorLevel.hpp +78 -0
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +99 -7
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +9 -2
- package/nitrogen/generated/android/c++/JRNIndoorBuilding.hpp +86 -0
- package/nitrogen/generated/android/c++/JRNIndoorLevel.hpp +66 -0
- 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/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +8 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/Func_void_RNIndoorBuilding.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/Func_void_RNIndoorLevel.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +42 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIndoorBuilding.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIndoorLevel.kt +38 -0
- 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.cpp +16 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +148 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +21 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +60 -5
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +10 -0
- package/nitrogen/generated/ios/swift/Func_void_RNIndoorBuilding.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_RNIndoorLevel.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +7 -2
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +122 -4
- package/nitrogen/generated/ios/swift/RNIndoorBuilding.swift +116 -0
- package/nitrogen/generated/ios/swift/RNIndoorLevel.swift +118 -0
- 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 +7 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +22 -3
- package/nitrogen/generated/shared/c++/RNIndoorBuilding.hpp +82 -0
- package/nitrogen/generated/shared/c++/RNIndoorLevel.hpp +80 -0
- 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/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +24 -0
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +4 -0
- package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +2 -0
- package/package.json +1 -1
- package/src/RNGoogleMapsPlusView.nitro.ts +19 -2
- package/src/types.ts +38 -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
|
|
@@ -15,6 +19,7 @@ import com.google.android.gms.maps.MapView
|
|
|
15
19
|
import com.google.android.gms.maps.model.CameraPosition
|
|
16
20
|
import com.google.android.gms.maps.model.Circle
|
|
17
21
|
import com.google.android.gms.maps.model.CircleOptions
|
|
22
|
+
import com.google.android.gms.maps.model.IndoorBuilding
|
|
18
23
|
import com.google.android.gms.maps.model.LatLng
|
|
19
24
|
import com.google.android.gms.maps.model.LatLngBounds
|
|
20
25
|
import com.google.android.gms.maps.model.MapColorScheme
|
|
@@ -28,9 +33,15 @@ import com.google.android.gms.maps.model.PolylineOptions
|
|
|
28
33
|
import com.google.android.gms.maps.model.TileOverlay
|
|
29
34
|
import com.google.android.gms.maps.model.TileOverlayOptions
|
|
30
35
|
import com.google.maps.android.data.kml.KmlLayer
|
|
36
|
+
import com.margelo.nitro.core.Promise
|
|
31
37
|
import com.rngooglemapsplus.extensions.toGooglePriority
|
|
32
38
|
import com.rngooglemapsplus.extensions.toLocationErrorCode
|
|
39
|
+
import com.rngooglemapsplus.extensions.toRNIndoorBuilding
|
|
40
|
+
import com.rngooglemapsplus.extensions.toRNIndoorLevel
|
|
33
41
|
import java.io.ByteArrayInputStream
|
|
42
|
+
import java.io.ByteArrayOutputStream
|
|
43
|
+
import java.io.File
|
|
44
|
+
import java.io.FileOutputStream
|
|
34
45
|
import java.nio.charset.StandardCharsets
|
|
35
46
|
|
|
36
47
|
class GoogleMapsViewImpl(
|
|
@@ -48,6 +59,7 @@ class GoogleMapsViewImpl(
|
|
|
48
59
|
GoogleMap.OnPolygonClickListener,
|
|
49
60
|
GoogleMap.OnCircleClickListener,
|
|
50
61
|
GoogleMap.OnMarkerDragListener,
|
|
62
|
+
GoogleMap.OnIndoorStateChangeListener,
|
|
51
63
|
LifecycleEventListener {
|
|
52
64
|
private var initialized = false
|
|
53
65
|
private var mapReady = false
|
|
@@ -184,6 +196,8 @@ class GoogleMapsViewImpl(
|
|
|
184
196
|
if (cameraPosition == lastSubmittedCameraPosition) {
|
|
185
197
|
return
|
|
186
198
|
}
|
|
199
|
+
lastSubmittedCameraPosition = cameraPosition
|
|
200
|
+
|
|
187
201
|
val isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason
|
|
188
202
|
|
|
189
203
|
val latDelta = bounds.northeast.latitude - bounds.southwest.latitude
|
|
@@ -203,7 +217,6 @@ class GoogleMapsViewImpl(
|
|
|
203
217
|
),
|
|
204
218
|
isGesture,
|
|
205
219
|
)
|
|
206
|
-
lastSubmittedCameraPosition = cameraPosition
|
|
207
220
|
}
|
|
208
221
|
|
|
209
222
|
override fun onCameraIdle() {
|
|
@@ -490,6 +503,8 @@ class GoogleMapsViewImpl(
|
|
|
490
503
|
var onMarkerDragStart: ((String?, RNLatLng) -> Unit)? = null
|
|
491
504
|
var onMarkerDrag: ((String?, RNLatLng) -> Unit)? = null
|
|
492
505
|
var onMarkerDragEnd: ((String?, RNLatLng) -> Unit)? = null
|
|
506
|
+
var onIndoorBuildingFocused: ((RNIndoorBuilding) -> Unit)? = null
|
|
507
|
+
var onIndoorLevelActivated: ((RNIndoorLevel) -> Unit)? = null
|
|
493
508
|
var onCameraChangeStart: ((RNRegion, RNCamera, Boolean) -> Unit)? = null
|
|
494
509
|
var onCameraChange: ((RNRegion, RNCamera, Boolean) -> Unit)? = null
|
|
495
510
|
var onCameraChangeComplete: ((RNRegion, RNCamera, Boolean) -> Unit)? = null
|
|
@@ -497,7 +512,7 @@ class GoogleMapsViewImpl(
|
|
|
497
512
|
fun setCamera(
|
|
498
513
|
cameraPosition: CameraPosition,
|
|
499
514
|
animated: Boolean,
|
|
500
|
-
|
|
515
|
+
durationMs: Int,
|
|
501
516
|
) {
|
|
502
517
|
onUi {
|
|
503
518
|
val current = googleMap?.cameraPosition
|
|
@@ -508,7 +523,7 @@ class GoogleMapsViewImpl(
|
|
|
508
523
|
val update = CameraUpdateFactory.newCameraPosition(cameraPosition)
|
|
509
524
|
|
|
510
525
|
if (animated) {
|
|
511
|
-
googleMap?.animateCamera(update,
|
|
526
|
+
googleMap?.animateCamera(update, durationMs, null)
|
|
512
527
|
} else {
|
|
513
528
|
googleMap?.moveCamera(update)
|
|
514
529
|
}
|
|
@@ -519,7 +534,7 @@ class GoogleMapsViewImpl(
|
|
|
519
534
|
coordinates: Array<RNLatLng>,
|
|
520
535
|
padding: RNMapPadding,
|
|
521
536
|
animated: Boolean,
|
|
522
|
-
|
|
537
|
+
durationMs: Int,
|
|
523
538
|
) {
|
|
524
539
|
if (coordinates.isEmpty()) {
|
|
525
540
|
return
|
|
@@ -577,13 +592,85 @@ class GoogleMapsViewImpl(
|
|
|
577
592
|
0,
|
|
578
593
|
)
|
|
579
594
|
if (animated) {
|
|
580
|
-
googleMap?.animateCamera(update,
|
|
595
|
+
googleMap?.animateCamera(update, durationMs, null)
|
|
581
596
|
} else {
|
|
582
597
|
googleMap?.moveCamera(update)
|
|
583
598
|
}
|
|
584
599
|
}
|
|
585
600
|
}
|
|
586
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
|
+
|
|
587
674
|
fun addMarker(
|
|
588
675
|
id: String,
|
|
589
676
|
opts: MarkerOptions,
|
|
@@ -1003,6 +1090,21 @@ class GoogleMapsViewImpl(
|
|
|
1003
1090
|
RNLatLng(marker.position.latitude, marker.position.longitude),
|
|
1004
1091
|
)
|
|
1005
1092
|
}
|
|
1093
|
+
|
|
1094
|
+
override fun onIndoorBuildingFocused() {
|
|
1095
|
+
val building = googleMap?.focusedBuilding ?: return
|
|
1096
|
+
onIndoorBuildingFocused?.invoke(building.toRNIndoorBuilding())
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
override fun onIndoorLevelActivated(indoorBuilding: IndoorBuilding) {
|
|
1100
|
+
val activeLevel = indoorBuilding.levels.getOrNull(indoorBuilding.activeLevelIndex) ?: return
|
|
1101
|
+
onIndoorLevelActivated?.invoke(
|
|
1102
|
+
activeLevel.toRNIndoorLevel(
|
|
1103
|
+
indoorBuilding.activeLevelIndex,
|
|
1104
|
+
true,
|
|
1105
|
+
),
|
|
1106
|
+
)
|
|
1107
|
+
}
|
|
1006
1108
|
}
|
|
1007
1109
|
|
|
1008
1110
|
private inline fun onUi(crossinline block: () -> Unit) {
|
|
@@ -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(
|
|
@@ -315,6 +320,16 @@ class RNGoogleMapsPlusView(
|
|
|
315
320
|
view.onMarkerDragEnd = cb
|
|
316
321
|
}
|
|
317
322
|
|
|
323
|
+
override var onIndoorBuildingFocused: ((RNIndoorBuilding) -> Unit)? = null
|
|
324
|
+
set(cb) {
|
|
325
|
+
view.onIndoorBuildingFocused = cb
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
override var onIndoorLevelActivated: ((RNIndoorLevel) -> Unit)? = null
|
|
329
|
+
set(cb) {
|
|
330
|
+
view.onIndoorLevelActivated = cb
|
|
331
|
+
}
|
|
332
|
+
|
|
318
333
|
override var onCameraChangeStart: ((RNRegion, RNCamera, Boolean) -> Unit)? = null
|
|
319
334
|
set(cb) {
|
|
320
335
|
view.onCameraChangeStart = cb
|
|
@@ -333,25 +348,54 @@ class RNGoogleMapsPlusView(
|
|
|
333
348
|
override fun setCamera(
|
|
334
349
|
camera: RNCamera,
|
|
335
350
|
animated: Boolean?,
|
|
336
|
-
|
|
351
|
+
durationMs: Double?,
|
|
337
352
|
) {
|
|
338
|
-
view.setCamera(camera.toCameraPosition(), animated == true,
|
|
353
|
+
view.setCamera(camera.toCameraPosition(), animated == true, durationMs?.toInt() ?: 3000)
|
|
339
354
|
}
|
|
340
355
|
|
|
341
356
|
override fun setCameraToCoordinates(
|
|
342
357
|
coordinates: Array<RNLatLng>,
|
|
343
358
|
padding: RNMapPadding?,
|
|
344
359
|
animated: Boolean?,
|
|
345
|
-
|
|
360
|
+
durationMs: Double?,
|
|
346
361
|
) {
|
|
347
362
|
view.setCameraToCoordinates(
|
|
348
363
|
coordinates,
|
|
349
364
|
padding = padding ?: RNMapPadding(0.0, 0.0, 0.0, 0.0),
|
|
350
365
|
animated == true,
|
|
351
|
-
|
|
366
|
+
durationMs?.toInt() ?: 3000,
|
|
352
367
|
)
|
|
353
368
|
}
|
|
354
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
|
+
|
|
355
399
|
override fun showLocationDialog() {
|
|
356
400
|
locationHandler.showLocationDialog()
|
|
357
401
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.google.android.gms.maps.model.IndoorBuilding
|
|
4
|
+
import com.google.android.gms.maps.model.IndoorLevel
|
|
5
|
+
import com.rngooglemapsplus.RNIndoorBuilding
|
|
6
|
+
import com.rngooglemapsplus.RNIndoorLevel
|
|
7
|
+
|
|
8
|
+
fun IndoorBuilding.toRNIndoorBuilding(): RNIndoorBuilding {
|
|
9
|
+
val mappedLevels =
|
|
10
|
+
levels
|
|
11
|
+
.mapIndexed { index, level ->
|
|
12
|
+
val active = index == activeLevelIndex
|
|
13
|
+
level.toRNIndoorLevel(index, active)
|
|
14
|
+
}.toTypedArray()
|
|
15
|
+
|
|
16
|
+
return RNIndoorBuilding(
|
|
17
|
+
activeLevelIndex = activeLevelIndex.toDouble(),
|
|
18
|
+
defaultLevelIndex = defaultLevelIndex.toDouble(),
|
|
19
|
+
levels = mappedLevels,
|
|
20
|
+
underground = isUnderground,
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
fun IndoorLevel.toRNIndoorLevel(
|
|
25
|
+
index: Int,
|
|
26
|
+
active: Boolean,
|
|
27
|
+
): RNIndoorLevel =
|
|
28
|
+
RNIndoorLevel(
|
|
29
|
+
index = index.toDouble(),
|
|
30
|
+
name = name,
|
|
31
|
+
shortName = shortName,
|
|
32
|
+
active = active,
|
|
33
|
+
)
|
|
@@ -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
|
+
}
|