Skip to content

Commit

Permalink
fix bug for manual location source on android
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianBissekkou committed Nov 30, 2023
1 parent eca8c59 commit 36d8a3a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ internal class ArcgisMapView(
val position = optionParams.parseToClass<UserPosition>()

dataSource.setNewLocation(position)
result.success(true)
}

private fun onSetLocationDisplayDataSourceType(call: MethodCall, result: MethodChannel.Result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ class GraphicsParser {

private fun parsePoint(map: Map<String, Any>): List<Graphic> {
val point = (map["point"] as Map<String, Any>).parseToClass<LatLng>()
val symbolMap = map["symbol"] as Map<String, Any>

val pointGraphic = Graphic().apply {
geometry = point.toAGSPoint()
symbol = parseSymbol(map)
symbol = parseSymbol(symbolMap)
}

return listOf(pointGraphic)
}

private fun parsePolyline(map: Map<String, Any>): List<Graphic> {
val points = parseToClass<List<List<List<Double>>>>(map["paths"]!!)
val symbolMap = map["symbol"] as Map<String, Any>

return points.map { subPoints ->
Graphic().apply {
Expand All @@ -72,26 +74,25 @@ class GraphicsParser {
if (z != null) Point(x, y, z, SpatialReferences.getWgs84())
else Point(x, y, SpatialReferences.getWgs84())
}))
symbol = parseSymbol(map)
symbol = parseSymbol(symbolMap)
}
}
}

private fun parsePolygon(map: Map<String, Any>): List<Graphic> {
val rings = parseToClass<List<List<List<Double>>>>(map["rings"]!!)
val symbolMap = map["symbol"] as Map<String, Any>

return rings.map { ring ->
Graphic().apply {
geometry =
Polygon(PointCollection(ring.map { LatLng(it[0], it[1]).toAGSPoint() }))
symbol = parseSymbol(map)
symbol = parseSymbol(symbolMap)
}
}
}

fun parseSymbol(map: Map<String, Any>): Symbol {
val symbolMap = map["symbol"] as Map<String, Any>

fun parseSymbol(symbolMap: Map<String, Any>): Symbol {
val symbol = when (val type = symbolMap["type"]) {
"simple-marker" -> parseSimpleMarkerSymbol(symbolMap)
"picture-marker" -> parsePictureMarkerSymbol(symbolMap)
Expand Down
4 changes: 4 additions & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
android:label="example"
android:name="${applicationName}"
Expand Down

0 comments on commit 36d8a3a

Please sign in to comment.