Skip to content

Commit 4d5535b

Browse files
committed
Basemap styles cleanup
1 parent cf25de6 commit 4d5535b

File tree

2 files changed

+125
-66
lines changed

2 files changed

+125
-66
lines changed

arcgis_map_sdk_android/android/src/main/kotlin/dev/fluttercommunity/arcgis_map_sdk_android/Parsing.kt

Lines changed: 125 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -178,73 +178,133 @@ fun parseAnimationCurve(value: String): AnimationCurve {
178178
}
179179
}
180180

181-
private val basemapStyleMapping = mapOf(
182-
BasemapStyle.ArcGISImagery to "arcgisImagery",
183-
BasemapStyle.ArcGISImageryStandard to "arcgisImageryStandard",
184-
BasemapStyle.ArcGISImageryLabels to "arcgisImageryLabels",
185-
BasemapStyle.ArcGISLightGray to "arcgisLightGray",
186-
BasemapStyle.ArcGISLightGrayBase to "arcgisLightGrayBase",
187-
BasemapStyle.ArcGISLightGrayLabels to "arcgisLightGrayLabels",
188-
BasemapStyle.ArcGISDarkGray to "arcgisDarkGray",
189-
BasemapStyle.ArcGISDarkGrayBase to "arcgisDarkGrayBase",
190-
BasemapStyle.ArcGISDarkGrayLabels to "arcgisDarkGrayLabels",
191-
BasemapStyle.ArcGISNavigation to "arcgisNavigation",
192-
BasemapStyle.ArcGISNavigationNight to "arcgisNavigationNight",
193-
BasemapStyle.ArcGISStreets to "arcgisStreets",
194-
BasemapStyle.ArcGISStreetsRelief to "arcgisStreetsRelief",
195-
BasemapStyle.ArcGISStreetsReliefBase to "arcgisStreetsReliefBase",
196-
BasemapStyle.ArcGISStreetsNight to "arcgisStreetsNight",
197-
BasemapStyle.ArcGISTopographic to "arcgisTopographic",
198-
BasemapStyle.ArcGISTopographicBase to "arcgisTopographicBase",
199-
BasemapStyle.ArcGISOceans to "arcgisOceans",
200-
BasemapStyle.ArcGISOceansBase to "arcgisOceansBase",
201-
BasemapStyle.ArcGISOceansLabels to "arcgisOceansLabels",
202-
BasemapStyle.ArcGISTerrain to "arcgisTerrain",
203-
BasemapStyle.ArcGISTerrainBase to "arcgisTerrainBase",
204-
BasemapStyle.ArcGISTerrainDetail to "arcgisTerrainDetail",
205-
BasemapStyle.ArcGISCommunity to "arcgisCommunity",
206-
BasemapStyle.ArcGISChartedTerritory to "arcgisChartedTerritory",
207-
BasemapStyle.ArcGISChartedTerritoryBase to "arcgisChartedTerritoryBase",
208-
BasemapStyle.ArcGISColoredPencil to "arcgisColoredPencil",
209-
BasemapStyle.ArcGISNova to "arcgisNova",
210-
BasemapStyle.ArcGISModernAntique to "arcgisModernAntique",
211-
BasemapStyle.ArcGISModernAntiqueBase to "arcgisModernAntiqueBase",
212-
BasemapStyle.ArcGISMidcentury to "arcgisMidcentury",
213-
BasemapStyle.ArcGISNewspaper to "arcgisNewspaper",
214-
BasemapStyle.ArcGISHillshadeLight to "arcgisHillshadeLight",
215-
BasemapStyle.ArcGISHillshadeDark to "arcgisHillshadeDark",
216-
BasemapStyle.ArcGISOutdoor to "arcgisOutdoor",
217-
BasemapStyle.ArcGISHumanGeography to "arcgisHumanGeography",
218-
BasemapStyle.ArcGISHumanGeographyBase to "arcgisHumanGeographyBase",
219-
BasemapStyle.ArcGISHumanGeographyDetail to "arcgisHumanGeographyDetail",
220-
BasemapStyle.ArcGISHumanGeographyLabels to "arcgisHumanGeographyLabels",
221-
BasemapStyle.ArcGISHumanGeographyDark to "arcgisHumanGeographyDark",
222-
BasemapStyle.ArcGISHumanGeographyDarkBase to "arcgisHumanGeographyDarkBase",
223-
BasemapStyle.ArcGISHumanGeographyDarkDetail to "arcgisHumanGeographyDarkDetail",
224-
BasemapStyle.ArcGISHumanGeographyDarkLabels to "arcgisHumanGeographyDarkLabels",
225-
BasemapStyle.OsmStandard to "osmStandard",
226-
BasemapStyle.OsmStandardRelief to "osmStandardRelief",
227-
BasemapStyle.OsmStandardReliefBase to "osmStandardReliefBase",
228-
BasemapStyle.OsmStreets to "osmStreets",
229-
BasemapStyle.OsmStreetsRelief to "osmStreetsRelief",
230-
BasemapStyle.OsmStreetsReliefBase to "osmStreetsReliefBase",
231-
BasemapStyle.OsmLightGray to "osmLightGray",
232-
BasemapStyle.OsmLightGrayBase to "osmLightGrayBase",
233-
BasemapStyle.OsmLightGrayLabels to "osmLightGrayLabels",
234-
BasemapStyle.OsmDarkGray to "osmDarkGray",
235-
BasemapStyle.OsmDarkGrayBase to "osmDarkGrayBase",
236-
BasemapStyle.OsmDarkGrayLabels to "osmDarkGrayLabels",
237-
BasemapStyle.OsmBlueprint to "osmBlueprint",
238-
BasemapStyle.OsmHybrid to "osmHybrid",
239-
BasemapStyle.OsmHybridDetail to "osmHybridDetail",
240-
BasemapStyle.OsmNavigation to "osmNavigation",
241-
BasemapStyle.OsmNavigationDark to "osmNavigationDark"
242-
)
243-
244181
fun BasemapStyle.getJsonValue(): String {
245-
return basemapStyleMapping[this]!!
182+
return when (this) {
183+
BasemapStyle.ArcGISImagery -> "arcgisImagery"
184+
BasemapStyle.ArcGISImageryStandard -> "arcgisImageryStandard"
185+
BasemapStyle.ArcGISImageryLabels -> "arcgisImageryLabels"
186+
BasemapStyle.ArcGISLightGray -> "arcgisLightGray"
187+
BasemapStyle.ArcGISLightGrayBase -> "arcgisLightGrayBase"
188+
BasemapStyle.ArcGISLightGrayLabels -> "arcgisLightGrayLabels"
189+
BasemapStyle.ArcGISDarkGray -> "arcgisDarkGray"
190+
BasemapStyle.ArcGISDarkGrayBase -> "arcgisDarkGrayBase"
191+
BasemapStyle.ArcGISDarkGrayLabels -> "arcgisDarkGrayLabels"
192+
BasemapStyle.ArcGISNavigation -> "arcgisNavigation"
193+
BasemapStyle.ArcGISNavigationNight -> "arcgisNavigationNight"
194+
BasemapStyle.ArcGISStreets -> "arcgisStreets"
195+
BasemapStyle.ArcGISStreetsRelief -> "arcgisStreetsRelief"
196+
BasemapStyle.ArcGISStreetsReliefBase -> "arcgisStreetsReliefBase"
197+
BasemapStyle.ArcGISStreetsNight -> "arcgisStreetsNight"
198+
BasemapStyle.ArcGISTopographic -> "arcgisTopographic"
199+
BasemapStyle.ArcGISTopographicBase -> "arcgisTopographicBase"
200+
BasemapStyle.ArcGISOceans -> "arcgisOceans"
201+
BasemapStyle.ArcGISOceansBase -> "arcgisOceansBase"
202+
BasemapStyle.ArcGISOceansLabels -> "arcgisOceansLabels"
203+
BasemapStyle.ArcGISTerrain -> "arcgisTerrain"
204+
BasemapStyle.ArcGISTerrainBase -> "arcgisTerrainBase"
205+
BasemapStyle.ArcGISTerrainDetail -> "arcgisTerrainDetail"
206+
BasemapStyle.ArcGISCommunity -> "arcgisCommunity"
207+
BasemapStyle.ArcGISChartedTerritory -> "arcgisChartedTerritory"
208+
BasemapStyle.ArcGISChartedTerritoryBase -> "arcgisChartedTerritoryBase"
209+
BasemapStyle.ArcGISColoredPencil -> "arcgisColoredPencil"
210+
BasemapStyle.ArcGISNova -> "arcgisNova"
211+
BasemapStyle.ArcGISModernAntique -> "arcgisModernAntique"
212+
BasemapStyle.ArcGISModernAntiqueBase -> "arcgisModernAntiqueBase"
213+
BasemapStyle.ArcGISMidcentury -> "arcgisMidcentury"
214+
BasemapStyle.ArcGISNewspaper -> "arcgisNewspaper"
215+
BasemapStyle.ArcGISHillshadeLight -> "arcgisHillshadeLight"
216+
BasemapStyle.ArcGISHillshadeDark -> "arcgisHillshadeDark"
217+
BasemapStyle.ArcGISOutdoor -> "arcgisOutdoor"
218+
BasemapStyle.ArcGISHumanGeography -> "arcgisHumanGeography"
219+
BasemapStyle.ArcGISHumanGeographyBase -> "arcgisHumanGeographyBase"
220+
BasemapStyle.ArcGISHumanGeographyDetail -> "arcgisHumanGeographyDetail"
221+
BasemapStyle.ArcGISHumanGeographyLabels -> "arcgisHumanGeographyLabels"
222+
BasemapStyle.ArcGISHumanGeographyDark -> "arcgisHumanGeographyDark"
223+
BasemapStyle.ArcGISHumanGeographyDarkBase -> "arcgisHumanGeographyDarkBase"
224+
BasemapStyle.ArcGISHumanGeographyDarkDetail -> "arcgisHumanGeographyDarkDetail"
225+
BasemapStyle.ArcGISHumanGeographyDarkLabels -> "arcgisHumanGeographyDarkLabels"
226+
BasemapStyle.OsmStandard -> "osmStandard"
227+
BasemapStyle.OsmStandardRelief -> "osmStandardRelief"
228+
BasemapStyle.OsmStandardReliefBase -> "osmStandardReliefBase"
229+
BasemapStyle.OsmStreets -> "osmStreets"
230+
BasemapStyle.OsmStreetsRelief -> "osmStreetsRelief"
231+
BasemapStyle.OsmStreetsReliefBase -> "osmStreetsReliefBase"
232+
BasemapStyle.OsmLightGray -> "osmLightGray"
233+
BasemapStyle.OsmLightGrayBase -> "osmLightGrayBase"
234+
BasemapStyle.OsmLightGrayLabels -> "osmLightGrayLabels"
235+
BasemapStyle.OsmDarkGray -> "osmDarkGray"
236+
BasemapStyle.OsmDarkGrayBase -> "osmDarkGrayBase"
237+
BasemapStyle.OsmDarkGrayLabels -> "osmDarkGrayLabels"
238+
BasemapStyle.OsmBlueprint -> "osmBlueprint"
239+
BasemapStyle.OsmHybrid -> "osmHybrid"
240+
BasemapStyle.OsmHybridDetail -> "osmHybridDetail"
241+
BasemapStyle.OsmNavigation -> "osmNavigation"
242+
BasemapStyle.OsmNavigationDark -> "osmNavigationDark"
243+
}
246244
}
247245

248246
fun parseBasemapStyle(value: String): BasemapStyle? {
249-
return basemapStyleMapping.entries.firstOrNull { it.value == value }?.key
247+
return when (value) {
248+
"arcgisImagery" -> BasemapStyle.ArcGISImagery
249+
"arcgisImageryStandard" -> BasemapStyle.ArcGISImageryStandard
250+
"arcgisImageryLabels" -> BasemapStyle.ArcGISImageryLabels
251+
"arcgisLightGray" -> BasemapStyle.ArcGISLightGray
252+
"arcgisLightGrayBase" -> BasemapStyle.ArcGISLightGrayBase
253+
"arcgisLightGrayLabels" -> BasemapStyle.ArcGISLightGrayLabels
254+
"arcgisDarkGray" -> BasemapStyle.ArcGISDarkGray
255+
"arcgisDarkGrayBase" -> BasemapStyle.ArcGISDarkGrayBase
256+
"arcgisDarkGrayLabels" -> BasemapStyle.ArcGISDarkGrayLabels
257+
"arcgisNavigation" -> BasemapStyle.ArcGISNavigation
258+
"arcgisNavigationNight" -> BasemapStyle.ArcGISNavigationNight
259+
"arcgisStreets" -> BasemapStyle.ArcGISStreets
260+
"arcgisStreetsRelief" -> BasemapStyle.ArcGISStreetsRelief
261+
"arcgisStreetsReliefBase" -> BasemapStyle.ArcGISStreetsReliefBase
262+
"arcgisStreetsNight" -> BasemapStyle.ArcGISStreetsNight
263+
"arcgisTopographic" -> BasemapStyle.ArcGISTopographic
264+
"arcgisTopographicBase" -> BasemapStyle.ArcGISTopographicBase
265+
"arcgisOceans" -> BasemapStyle.ArcGISOceans
266+
"arcgisOceansBase" -> BasemapStyle.ArcGISOceansBase
267+
"arcgisOceansLabels" -> BasemapStyle.ArcGISOceansLabels
268+
"arcgisTerrain" -> BasemapStyle.ArcGISTerrain
269+
"arcgisTerrainBase" -> BasemapStyle.ArcGISTerrainBase
270+
"arcgisTerrainDetail" -> BasemapStyle.ArcGISTerrainDetail
271+
"arcgisCommunity" -> BasemapStyle.ArcGISCommunity
272+
"arcgisChartedTerritory" -> BasemapStyle.ArcGISChartedTerritory
273+
"arcgisChartedTerritoryBase" -> BasemapStyle.ArcGISChartedTerritoryBase
274+
"arcgisColoredPencil" -> BasemapStyle.ArcGISColoredPencil
275+
"arcgisNova" -> BasemapStyle.ArcGISNova
276+
"arcgisModernAntique" -> BasemapStyle.ArcGISModernAntique
277+
"arcgisModernAntiqueBase" -> BasemapStyle.ArcGISModernAntiqueBase
278+
"arcgisMidcentury" -> BasemapStyle.ArcGISMidcentury
279+
"arcgisNewspaper" -> BasemapStyle.ArcGISNewspaper
280+
"arcgisHillshadeLight" -> BasemapStyle.ArcGISHillshadeLight
281+
"arcgisHillshadeDark" -> BasemapStyle.ArcGISHillshadeDark
282+
"arcgisOutdoor" -> BasemapStyle.ArcGISOutdoor
283+
"arcgisHumanGeography" -> BasemapStyle.ArcGISHumanGeography
284+
"arcgisHumanGeographyBase" -> BasemapStyle.ArcGISHumanGeographyBase
285+
"arcgisHumanGeographyDetail" -> BasemapStyle.ArcGISHumanGeographyDetail
286+
"arcgisHumanGeographyLabels" -> BasemapStyle.ArcGISHumanGeographyLabels
287+
"arcgisHumanGeographyDark" -> BasemapStyle.ArcGISHumanGeographyDark
288+
"arcgisHumanGeographyDarkBase" -> BasemapStyle.ArcGISHumanGeographyDarkBase
289+
"arcgisHumanGeographyDarkDetail" -> BasemapStyle.ArcGISHumanGeographyDarkDetail
290+
"arcgisHumanGeographyDarkLabels" -> BasemapStyle.ArcGISHumanGeographyDarkLabels
291+
"osmStandard" -> BasemapStyle.OsmStandard
292+
"osmStandardRelief" -> BasemapStyle.OsmStandardRelief
293+
"osmStandardReliefBase" -> BasemapStyle.OsmStandardReliefBase
294+
"osmStreets" -> BasemapStyle.OsmStreets
295+
"osmStreetsRelief" -> BasemapStyle.OsmStreetsRelief
296+
"osmStreetsReliefBase" -> BasemapStyle.OsmStreetsReliefBase
297+
"osmLightGray" -> BasemapStyle.OsmLightGray
298+
"osmLightGrayBase" -> BasemapStyle.OsmLightGrayBase
299+
"osmLightGrayLabels" -> BasemapStyle.OsmLightGrayLabels
300+
"osmDarkGray" -> BasemapStyle.OsmDarkGray
301+
"osmDarkGrayBase" -> BasemapStyle.OsmDarkGrayBase
302+
"osmDarkGrayLabels" -> BasemapStyle.OsmDarkGrayLabels
303+
"osmBlueprint" -> BasemapStyle.OsmBlueprint
304+
"osmHybrid" -> BasemapStyle.OsmHybrid
305+
"osmHybridDetail" -> BasemapStyle.OsmHybridDetail
306+
"osmNavigation" -> BasemapStyle.OsmNavigation
307+
"osmNavigationDark" -> BasemapStyle.OsmNavigationDark
308+
else -> null
309+
}
250310
}

example/lib/basemap_style_example_page.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:arcgis_map_sdk/arcgis_map_sdk.dart';
77
import 'package:flutter/foundation.dart';
88
import 'package:flutter/material.dart';
99

10-
/// Example 3D SceneLayer page.
1110
class BasemapStyleExamplePage extends StatefulWidget {
1211
const BasemapStyleExamplePage({super.key});
1312

0 commit comments

Comments
 (0)