-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMapPolygon.kt
More file actions
36 lines (33 loc) · 1.09 KB
/
MapPolygon.kt
File metadata and controls
36 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.rngooglemapsplus
import com.facebook.react.uimanager.PixelUtil.dpToPx
import com.google.android.gms.maps.model.PolygonOptions
class MapPolygonOptions {
fun buildPolygonOptions(poly: RNPolygon): PolygonOptions =
PolygonOptions().apply {
poly.coordinates.forEach { pt ->
add(
com.google.android.gms.maps.model
.LatLng(pt.latitude, pt.longitude),
)
}
poly.fillColor?.let { fillColor(it.toColor()) }
poly.strokeColor?.let { strokeColor(it.toColor()) }
poly.strokeWidth?.let { strokeWidth(it.dpToPx()) }
zIndex(poly.zIndex.toFloat())
}
}
fun RNPolygon.polygonEquals(b: RNPolygon): Boolean {
if (zIndex != b.zIndex) return false
if (strokeWidth != b.strokeWidth) return false
if (fillColor != b.fillColor) return false
if (strokeColor != b.strokeColor) return false
val ac = coordinates
val bc = b.coordinates
if (ac.size != bc.size) return false
for (i in ac.indices) {
val p = ac[i]
val q = bc[i]
if (p.latitude != q.latitude || p.longitude != q.longitude) return false
}
return true
}