react-native-google-maps-plus 1.0.2 → 1.1.0-dev.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/README.md +127 -11
- package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +359 -139
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +44 -44
- package/android/src/main/java/com/rngooglemapsplus/MapCircleBuilder.kt +19 -0
- package/android/src/main/java/com/rngooglemapsplus/{MapMarker.kt → MapMarkerBuilder.kt} +7 -6
- package/android/src/main/java/com/rngooglemapsplus/{MapPolygon.kt → MapPolygonBuilder.kt} +4 -18
- package/android/src/main/java/com/rngooglemapsplus/{MapPolyline.kt → MapPolylineBuilder.kt.kt} +4 -19
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +145 -129
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNCameraExtension.kt +19 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNLocationPriorityExtension.kt +12 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNMapCircleExtension.kt +14 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNPolygonExtension.kt +20 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNPolylineExtension.kt +21 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNUserInterfaceExtension.kt +12 -0
- package/android/src/main/java/com/rngooglemapsplus/{Color.kt → extensions/StringExtension.kt} +1 -1
- package/android/src/main/java/com/rngooglemapsplus/extensions/ThrowableExtension.kt +38 -0
- package/ios/GoogleMapViewImpl.swift +348 -150
- package/ios/LocationHandler.swift +29 -69
- package/ios/MapCircleBuilder.swift +20 -0
- package/ios/{MapMarker.swift → MapMarkerBuilder.swift} +11 -42
- package/ios/MapPolygonBuilder.swift +20 -0
- package/ios/MapPolylineBuilder.swift +24 -0
- package/ios/PermissionHandler.swift +1 -1
- package/ios/RNGoogleMapsPlusModule.swift +1 -1
- package/ios/RNGoogleMapsPlusView.swift +159 -168
- package/ios/extensions/RNCamera+Extension.swift +22 -0
- package/ios/extensions/RNCircle+Extension.swift +24 -0
- package/ios/extensions/RNIOSLocationAccuracy+Extensions.swift +19 -0
- package/ios/extensions/RNMarker+Extension.swift +24 -0
- package/ios/{MapPolygon.swift → extensions/RNPolygon+Extension.swift.swift} +7 -23
- package/ios/extensions/RNPolyline+Extension.swift.swift +62 -0
- package/ios/extensions/RNUserInterface+Extension.swift +16 -0
- package/ios/{Color.swift → extensions/String+Extensions.swift} +20 -20
- package/lib/module/types.js +14 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts +21 -12
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +59 -3
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +233 -69
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +40 -22
- package/nitrogen/generated/android/c++/JRNAndroidLocationConfig.hpp +63 -0
- package/nitrogen/generated/android/c++/JRNAndroidLocationPriority.hpp +65 -0
- package/nitrogen/generated/android/c++/JRNCircle.hpp +84 -0
- package/nitrogen/generated/android/c++/JRNIOSLocationAccuracy.hpp +65 -0
- package/nitrogen/generated/android/c++/JRNIOSLocationConfig.hpp +59 -0
- package/nitrogen/generated/android/c++/JRNInitialProps.hpp +66 -0
- package/nitrogen/generated/android/c++/JRNLocationConfig.hpp +65 -0
- package/nitrogen/generated/android/c++/JRNMapType.hpp +68 -0
- package/nitrogen/generated/android/c++/JRNMapUiSettings.hpp +93 -0
- package/nitrogen/generated/android/c++/JRNMarker.hpp +4 -4
- package/nitrogen/generated/android/c++/JRNPolygon.hpp +8 -4
- package/nitrogen/generated/android/c++/JRNPolyline.hpp +8 -4
- package/nitrogen/generated/android/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +40 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +89 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNAndroidLocationConfig.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNAndroidLocationPriority.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNCircle.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIOSLocationAccuracy.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIOSLocationConfig.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNInitialProps.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationConfig.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapType.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapUiSettings.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarker.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolygon.kt +4 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolyline.kt +4 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/views/HybridRNGoogleMapsPlusViewManager.kt +7 -1
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +296 -45
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +27 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +131 -37
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +61 -16
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +20 -11
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +378 -45
- package/nitrogen/generated/ios/swift/RNAndroidLocationConfig.swift +93 -0
- package/nitrogen/generated/ios/swift/RNAndroidLocationPriority.swift +48 -0
- package/nitrogen/generated/ios/swift/RNCircle.swift +198 -0
- package/nitrogen/generated/ios/swift/RNIOSLocationAccuracy.swift +48 -0
- package/nitrogen/generated/ios/swift/RNIOSLocationConfig.swift +70 -0
- package/nitrogen/generated/ios/swift/RNInitialProps.swift +107 -0
- package/nitrogen/generated/ios/swift/RNLocationConfig.swift +84 -0
- package/nitrogen/generated/ios/swift/RNMapType.swift +52 -0
- package/nitrogen/generated/ios/swift/RNMapUiSettings.swift +277 -0
- package/nitrogen/generated/ios/swift/RNMarker.swift +17 -5
- package/nitrogen/generated/ios/swift/RNPolygon.swift +40 -5
- package/nitrogen/generated/ios/swift/RNPolyline.swift +40 -5
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +20 -2
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +59 -26
- package/nitrogen/generated/shared/c++/RNAndroidLocationConfig.hpp +77 -0
- package/nitrogen/generated/shared/c++/RNAndroidLocationPriority.hpp +64 -0
- package/nitrogen/generated/shared/c++/RNCircle.hpp +98 -0
- package/nitrogen/generated/shared/c++/RNIOSLocationAccuracy.hpp +64 -0
- package/nitrogen/generated/shared/c++/RNIOSLocationConfig.hpp +73 -0
- package/nitrogen/generated/shared/c++/RNInitialProps.hpp +78 -0
- package/nitrogen/generated/shared/c++/RNLocationConfig.hpp +76 -0
- package/nitrogen/generated/shared/c++/RNMapType.hpp +88 -0
- package/nitrogen/generated/shared/c++/RNMapUiSettings.hpp +107 -0
- package/nitrogen/generated/shared/c++/RNMarker.hpp +6 -6
- package/nitrogen/generated/shared/c++/RNPolygon.hpp +10 -6
- package/nitrogen/generated/shared/c++/RNPolyline.hpp +10 -6
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +138 -30
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +27 -13
- package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +10 -1
- package/package.json +5 -5
- package/src/RNGoogleMapsPlusView.nitro.ts +25 -11
- package/src/types.ts +67 -3
- package/ios/MapPolyline.swift +0 -83
|
@@ -10,8 +10,6 @@ import com.facebook.react.bridge.ReactContext
|
|
|
10
10
|
import com.facebook.react.bridge.UiThreadUtil
|
|
11
11
|
import com.google.android.gms.common.ConnectionResult
|
|
12
12
|
import com.google.android.gms.common.GoogleApiAvailability
|
|
13
|
-
import com.google.android.gms.common.api.ApiException
|
|
14
|
-
import com.google.android.gms.common.api.CommonStatusCodes
|
|
15
13
|
import com.google.android.gms.common.api.ResolvableApiException
|
|
16
14
|
import com.google.android.gms.location.FusedLocationProviderClient
|
|
17
15
|
import com.google.android.gms.location.LocationCallback
|
|
@@ -19,22 +17,43 @@ import com.google.android.gms.location.LocationRequest
|
|
|
19
17
|
import com.google.android.gms.location.LocationResult
|
|
20
18
|
import com.google.android.gms.location.LocationServices
|
|
21
19
|
import com.google.android.gms.location.LocationSettingsRequest
|
|
22
|
-
import com.google.android.gms.location.LocationSettingsStatusCodes
|
|
23
20
|
import com.google.android.gms.location.Priority
|
|
21
|
+
import com.google.android.gms.maps.LocationSource
|
|
24
22
|
import com.google.android.gms.tasks.OnSuccessListener
|
|
23
|
+
import com.rngooglemapsplus.extensions.toLocationErrorCode
|
|
25
24
|
|
|
26
25
|
private const val REQ_LOCATION_SETTINGS = 2001
|
|
26
|
+
private const val PRIORITY_DEFAULT = Priority.PRIORITY_BALANCED_POWER_ACCURACY
|
|
27
|
+
private const val INTERVAL_DEFAULT = 600000L
|
|
28
|
+
private const val MIN_UPDATE_INTERVAL = 3600000L
|
|
27
29
|
|
|
28
30
|
class LocationHandler(
|
|
29
31
|
val context: ReactContext,
|
|
30
|
-
) {
|
|
32
|
+
) : LocationSource {
|
|
31
33
|
private val fusedLocationClientProviderClient: FusedLocationProviderClient =
|
|
32
34
|
LocationServices.getFusedLocationProviderClient(context)
|
|
35
|
+
private var listener: LocationSource.OnLocationChangedListener? = null
|
|
33
36
|
private var locationRequest: LocationRequest? = null
|
|
34
37
|
private var locationCallback: LocationCallback? = null
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
|
|
39
|
+
var priority: Int? = PRIORITY_DEFAULT
|
|
40
|
+
set(value) {
|
|
41
|
+
field = value
|
|
42
|
+
start()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var interval: Long? = INTERVAL_DEFAULT
|
|
46
|
+
set(value) {
|
|
47
|
+
field = value
|
|
48
|
+
buildLocationRequest()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var minUpdateInterval: Long? = MIN_UPDATE_INTERVAL
|
|
52
|
+
set(value) {
|
|
53
|
+
field = value
|
|
54
|
+
buildLocationRequest()
|
|
55
|
+
}
|
|
56
|
+
|
|
38
57
|
var onUpdate: ((Location) -> Unit)? = null
|
|
39
58
|
var onError: ((RNLocationErrorCode) -> Unit)? = null
|
|
40
59
|
|
|
@@ -90,6 +109,10 @@ class LocationHandler(
|
|
|
90
109
|
|
|
91
110
|
@Suppress("deprecation")
|
|
92
111
|
private fun buildLocationRequest() {
|
|
112
|
+
val priority = priority ?: Priority.PRIORITY_BALANCED_POWER_ACCURACY
|
|
113
|
+
val interval = interval ?: INTERVAL_DEFAULT
|
|
114
|
+
val minUpdateInterval = minUpdateInterval ?: MIN_UPDATE_INTERVAL
|
|
115
|
+
|
|
93
116
|
locationRequest =
|
|
94
117
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
95
118
|
LocationRequest
|
|
@@ -106,21 +129,6 @@ class LocationHandler(
|
|
|
106
129
|
restartLocationUpdates()
|
|
107
130
|
}
|
|
108
131
|
|
|
109
|
-
fun setPriority(priority: Int) {
|
|
110
|
-
this.priority = priority
|
|
111
|
-
buildLocationRequest()
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
fun setInterval(interval: Int) {
|
|
115
|
-
this.interval = interval.toLong()
|
|
116
|
-
buildLocationRequest()
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
fun setFastestInterval(fastestInterval: Int) {
|
|
120
|
-
this.minUpdateInterval = fastestInterval.toLong()
|
|
121
|
-
buildLocationRequest()
|
|
122
|
-
}
|
|
123
|
-
|
|
124
132
|
private fun restartLocationUpdates() {
|
|
125
133
|
stop()
|
|
126
134
|
// 4) Google Play Services checken – früh zurückmelden
|
|
@@ -146,7 +154,7 @@ class LocationHandler(
|
|
|
146
154
|
}
|
|
147
155
|
},
|
|
148
156
|
).addOnFailureListener { e ->
|
|
149
|
-
val error =
|
|
157
|
+
val error = e.toLocationErrorCode(context)
|
|
150
158
|
onError?.invoke(error)
|
|
151
159
|
}
|
|
152
160
|
locationCallback =
|
|
@@ -154,6 +162,7 @@ class LocationHandler(
|
|
|
154
162
|
override fun onLocationResult(locationResult: LocationResult) {
|
|
155
163
|
val location = locationResult.lastLocation
|
|
156
164
|
if (location != null) {
|
|
165
|
+
listener?.onLocationChanged(location)
|
|
157
166
|
onUpdate?.invoke(location)
|
|
158
167
|
} else {
|
|
159
168
|
onError?.invoke(RNLocationErrorCode.POSITION_UNAVAILABLE)
|
|
@@ -166,40 +175,31 @@ class LocationHandler(
|
|
|
166
175
|
locationCallback!!,
|
|
167
176
|
Looper.getMainLooper(),
|
|
168
177
|
).addOnFailureListener { e ->
|
|
169
|
-
val error =
|
|
178
|
+
val error = e.toLocationErrorCode(context)
|
|
170
179
|
onError?.invoke(error)
|
|
171
180
|
}
|
|
172
181
|
} catch (se: SecurityException) {
|
|
173
182
|
onError?.invoke(RNLocationErrorCode.PERMISSION_DENIED)
|
|
174
183
|
} catch (ex: Exception) {
|
|
175
|
-
val error =
|
|
184
|
+
val error = ex.toLocationErrorCode(context)
|
|
176
185
|
onError?.invoke(error)
|
|
177
186
|
}
|
|
178
187
|
}
|
|
179
188
|
|
|
180
|
-
private fun mapThrowableToCode(t: Throwable): RNLocationErrorCode {
|
|
181
|
-
if (t is SecurityException) return RNLocationErrorCode.PERMISSION_DENIED
|
|
182
|
-
if (t.message?.contains("GoogleApi", ignoreCase = true) == true) {
|
|
183
|
-
val gms = GoogleApiAvailability.getInstance()
|
|
184
|
-
val status = gms.isGooglePlayServicesAvailable(context)
|
|
185
|
-
if (status != ConnectionResult.SUCCESS) return RNLocationErrorCode.PLAY_SERVICE_NOT_AVAILABLE
|
|
186
|
-
}
|
|
187
|
-
if (t is ApiException) {
|
|
188
|
-
when (t.statusCode) {
|
|
189
|
-
CommonStatusCodes.NETWORK_ERROR -> return RNLocationErrorCode.POSITION_UNAVAILABLE
|
|
190
|
-
LocationSettingsStatusCodes.RESOLUTION_REQUIRED,
|
|
191
|
-
LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE,
|
|
192
|
-
-> return RNLocationErrorCode.SETTINGS_NOT_SATISFIED
|
|
193
|
-
}
|
|
194
|
-
return RNLocationErrorCode.INTERNAL_ERROR
|
|
195
|
-
}
|
|
196
|
-
return RNLocationErrorCode.INTERNAL_ERROR
|
|
197
|
-
}
|
|
198
|
-
|
|
199
189
|
fun stop() {
|
|
190
|
+
listener = null
|
|
200
191
|
if (locationCallback != null) {
|
|
201
192
|
fusedLocationClientProviderClient.removeLocationUpdates(locationCallback!!)
|
|
202
193
|
locationCallback = null
|
|
203
194
|
}
|
|
204
195
|
}
|
|
196
|
+
|
|
197
|
+
override fun activate(listener: LocationSource.OnLocationChangedListener) {
|
|
198
|
+
this.listener = listener
|
|
199
|
+
start()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
override fun deactivate() {
|
|
203
|
+
stop()
|
|
204
|
+
}
|
|
205
205
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.rngooglemapsplus
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
4
|
+
import com.google.android.gms.maps.model.CircleOptions
|
|
5
|
+
import com.google.android.gms.maps.model.LatLng
|
|
6
|
+
import com.rngooglemapsplus.extensions.toColor
|
|
7
|
+
|
|
8
|
+
class MapCircleBuilder {
|
|
9
|
+
fun buildCircleOptions(circle: RNCircle): CircleOptions =
|
|
10
|
+
CircleOptions().apply {
|
|
11
|
+
center(LatLng(circle.center.latitude, circle.center.longitude))
|
|
12
|
+
circle.radius?.let { radius(it) }
|
|
13
|
+
circle.strokeWidth?.let { strokeWidth(it.dpToPx()) }
|
|
14
|
+
circle.strokeColor?.let { strokeColor(it.toColor()) }
|
|
15
|
+
circle.fillColor?.let { fillColor(it.toColor()) }
|
|
16
|
+
circle.pressable?.let { clickable(it) }
|
|
17
|
+
circle.zIndex?.let { zIndex(it.toFloat()) }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -19,7 +19,7 @@ import kotlinx.coroutines.launch
|
|
|
19
19
|
import kotlinx.coroutines.withContext
|
|
20
20
|
import kotlin.coroutines.coroutineContext
|
|
21
21
|
|
|
22
|
-
class
|
|
22
|
+
class MarkerBuilder(
|
|
23
23
|
private val scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default),
|
|
24
24
|
) {
|
|
25
25
|
private val iconCache =
|
|
@@ -36,11 +36,12 @@ class MarkerOptions(
|
|
|
36
36
|
m: RNMarker,
|
|
37
37
|
icon: BitmapDescriptor,
|
|
38
38
|
): MarkerOptions =
|
|
39
|
-
MarkerOptions()
|
|
40
|
-
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
MarkerOptions().apply {
|
|
40
|
+
position(LatLng(m.coordinate.latitude, m.coordinate.longitude))
|
|
41
|
+
anchor((m.anchor?.x ?: 0.5).toFloat(), (m.anchor?.y ?: 0.5).toFloat())
|
|
42
|
+
icon(icon)
|
|
43
|
+
m.zIndex?.let { zIndex(it.toFloat()) }
|
|
44
|
+
}
|
|
44
45
|
|
|
45
46
|
fun buildIconAsync(
|
|
46
47
|
id: String,
|
|
@@ -2,8 +2,9 @@ package com.rngooglemapsplus
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.uimanager.PixelUtil.dpToPx
|
|
4
4
|
import com.google.android.gms.maps.model.PolygonOptions
|
|
5
|
+
import com.rngooglemapsplus.extensions.toColor
|
|
5
6
|
|
|
6
|
-
class
|
|
7
|
+
class MapPolygonBuilder {
|
|
7
8
|
fun buildPolygonOptions(poly: RNPolygon): PolygonOptions =
|
|
8
9
|
PolygonOptions().apply {
|
|
9
10
|
poly.coordinates.forEach { pt ->
|
|
@@ -15,22 +16,7 @@ class MapPolygonOptions {
|
|
|
15
16
|
poly.fillColor?.let { fillColor(it.toColor()) }
|
|
16
17
|
poly.strokeColor?.let { strokeColor(it.toColor()) }
|
|
17
18
|
poly.strokeWidth?.let { strokeWidth(it.dpToPx()) }
|
|
18
|
-
|
|
19
|
+
poly.pressable?.let { clickable(it) }
|
|
20
|
+
poly.zIndex?.let { zIndex(it.toFloat()) }
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
|
-
|
|
22
|
-
fun RNPolygon.polygonEquals(b: RNPolygon): Boolean {
|
|
23
|
-
if (zIndex != b.zIndex) return false
|
|
24
|
-
if (strokeWidth != b.strokeWidth) return false
|
|
25
|
-
if (fillColor != b.fillColor) return false
|
|
26
|
-
if (strokeColor != b.strokeColor) return false
|
|
27
|
-
val ac = coordinates
|
|
28
|
-
val bc = b.coordinates
|
|
29
|
-
if (ac.size != bc.size) return false
|
|
30
|
-
for (i in ac.indices) {
|
|
31
|
-
val p = ac[i]
|
|
32
|
-
val q = bc[i]
|
|
33
|
-
if (p.latitude != q.latitude || p.longitude != q.longitude) return false
|
|
34
|
-
}
|
|
35
|
-
return true
|
|
36
|
-
}
|
package/android/src/main/java/com/rngooglemapsplus/{MapPolyline.kt → MapPolylineBuilder.kt.kt}
RENAMED
|
@@ -7,8 +7,9 @@ import com.google.android.gms.maps.model.JointType
|
|
|
7
7
|
import com.google.android.gms.maps.model.PolylineOptions
|
|
8
8
|
import com.google.android.gms.maps.model.RoundCap
|
|
9
9
|
import com.google.android.gms.maps.model.SquareCap
|
|
10
|
+
import com.rngooglemapsplus.extensions.toColor
|
|
10
11
|
|
|
11
|
-
class
|
|
12
|
+
class MapPolylineBuilder {
|
|
12
13
|
fun buildPolylineOptions(pl: RNPolyline): PolylineOptions =
|
|
13
14
|
PolylineOptions().apply {
|
|
14
15
|
pl.coordinates.forEach { pt ->
|
|
@@ -22,7 +23,8 @@ class MapPolylineOptions {
|
|
|
22
23
|
pl.lineCap?.let { endCap(mapLineCap(it)) }
|
|
23
24
|
pl.lineJoin?.let { jointType(mapLineJoin(it)) }
|
|
24
25
|
pl.color?.let { color(it.toColor()) }
|
|
25
|
-
|
|
26
|
+
pl.pressable?.let { clickable(it) }
|
|
27
|
+
pl.zIndex?.let { zIndex(it.toFloat()) }
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
fun mapLineCap(type: RNLineCapType?): Cap =
|
|
@@ -40,20 +42,3 @@ class MapPolylineOptions {
|
|
|
40
42
|
null -> JointType.DEFAULT
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
|
-
|
|
44
|
-
fun RNPolyline.polylineEquals(b: RNPolyline): Boolean {
|
|
45
|
-
if (zIndex != b.zIndex) return false
|
|
46
|
-
if ((width ?: 0.0) != (b.width ?: 0.0)) return false
|
|
47
|
-
if (lineCap != b.lineCap) return false
|
|
48
|
-
if (lineJoin != b.lineJoin) return false
|
|
49
|
-
if (color != b.color) return false
|
|
50
|
-
val ac = coordinates
|
|
51
|
-
val bc = b.coordinates
|
|
52
|
-
if (ac.size != bc.size) return false
|
|
53
|
-
for (i in ac.indices) {
|
|
54
|
-
val p = ac[i]
|
|
55
|
-
val q = bc[i]
|
|
56
|
-
if (p.latitude != q.latitude || p.longitude != q.longitude) return false
|
|
57
|
-
}
|
|
58
|
-
return true
|
|
59
|
-
}
|