|
| 1 | +# Geo-Compose |
| 2 | + |
| 3 | +The Geo-Compose module provides `@Composable` implementations of the `MapView` and `SceneView` with a Compose-idiomatic API. |
| 4 | + |
| 5 | +|Geo-Compose| |
| 6 | +|:--:| |
| 7 | +|| |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +### Display a Map |
| 12 | + |
| 13 | +Displaying a map on the screen looks like this: |
| 14 | + |
| 15 | +```kotlin |
| 16 | +val arcGISMap = remember { ArcGISMap(BasemapStyle.ArcGISImagery) } |
| 17 | +MapView( |
| 18 | + modifier = Modifier.fillMaxSize(), |
| 19 | + arcGISMap = arcGISMap |
| 20 | +) |
| 21 | +``` |
| 22 | + |
| 23 | +### Respond to User Input |
| 24 | + |
| 25 | +The composable `MapView` and `SceneView` expose gesture events as lambda callback parameters: |
| 26 | + |
| 27 | +```kotlin |
| 28 | +val arcGISMap = remember { ArcGISMap(BasemapStyle.ArcGISImagery) } |
| 29 | +MapView( |
| 30 | + modifier = Modifier.fillMaxSize(), |
| 31 | + arcGISMap = arcGISMap, |
| 32 | + onSingleTapConfirmed = { singleTapConfirmedEvent -> |
| 33 | + val x = singleTapConfirmedEvent.screenCoordinate.x |
| 34 | + val y = singleTapConfirmedEvent.screenCoordinate.y |
| 35 | + Log.i("MapView", "Single tap at $x, $y") |
| 36 | + } |
| 37 | +) |
| 38 | +``` |
| 39 | + |
| 40 | +### Set a Viewpoint |
| 41 | + |
| 42 | +Setting the viewpoint of the `MapView` is handled by a parameter to the composable function. |
| 43 | + |
| 44 | +```kotlin |
| 45 | +val point = Point(-117.182541, 34.055569, SpatialReference.wgs84()) |
| 46 | +val scale = 170000.0 |
| 47 | +val viewpointOperation = remember { MapViewpointOperation.Set(Viewpoint(point, scale)) } |
| 48 | + |
| 49 | +MapView( |
| 50 | + modifier = Modifier.fillMaxSize(), |
| 51 | + arcGISMap = remember { ArcGISMap(BasemapStyle.ArcGISImagery) }, |
| 52 | + viewpointOperation = viewpointOperation |
| 53 | +) |
| 54 | +``` |
| 55 | + |
| 56 | +Examples of how to use `MapViewpointOperation` and `SceneViewpointOperation` are available in the respective microapps: |
| 57 | + |
| 58 | +- [MapView Set Viewpoint App](../../microapps/MapViewSetViewpointApp/README.md) |
| 59 | +- [SceneView Set Viewpoint App](../../microapps/SceneViewSetViewpointApp/README.md) |
| 60 | + |
| 61 | +### Display the Device Location |
| 62 | + |
| 63 | +A `LocationDisplay` can be used to display the device's location as a blue dot on a `MapView`: |
| 64 | + |
| 65 | +```kotlin |
| 66 | +val arcGISMap = remember { ArcGISMap(BasemapStyle.ArcGISImagery) } |
| 67 | +val scope = rememberCoroutineScope() |
| 68 | +val locationDisplay = rememberLocationDisplay { |
| 69 | + start(scope) |
| 70 | +} |
| 71 | +MapView( |
| 72 | + modifier = Modifier.fillMaxSize(), |
| 73 | + arcGISMap = remember { ArcGISMap(BasemapStyle.ArcGISImagery) }, |
| 74 | + locationDisplay = locationDisplay |
| 75 | +) |
| 76 | +``` |
| 77 | + |
| 78 | +An example of how to display the device location is available in the [MapView Location Display App](../../microapps/MapViewLocationDisplayApp/README.md). |
| 79 | + |
| 80 | +### Identify a Feature |
| 81 | + |
| 82 | +To identify a feature, create a `MapViewProxy` and call `identify()` on it after the `MapView` is displayed on screen |
| 83 | + |
| 84 | +```kotlin |
| 85 | +val mapViewProxy = remember { MapViewProxy() } |
| 86 | +val arcGISMap = remember { ArcGISMap(BasemapStyle.ArcGISImagery) } |
| 87 | +val scope = rememberCoroutineScope() |
| 88 | +MapView( |
| 89 | + modifier = Modifier.fillMaxSize(), |
| 90 | + arcGISMap = arcGISMap, |
| 91 | + mapViewProxy = mapViewProxy, |
| 92 | + onSingleTapConfirmed = { singleTapConfirmedEvent -> |
| 93 | + scope.launch { |
| 94 | + mapViewProxy.identify(featureLayer, singleTapConfirmedEvent.screenCoordinate, 20.dp) |
| 95 | + } |
| 96 | + } |
| 97 | +) |
| 98 | +``` |
| 99 | + |
| 100 | +An example of how to identify features and graphics is available in the [MapView Identify App](../../microapps/MapViewIdentifyApp/README.md). |
| 101 | + |
| 102 | +### Other Examples: |
| 103 | + |
| 104 | +Other microapps that demonstrate various workflows with the composable `MapView` and `SceneView` are available: |
| 105 | + |
| 106 | +- [MapView Geometry Editor App](../../microapps/MapViewGeometryEditorApp/README.md) demonstrates the use of `GeometryEditor` and `GraphicsOverlay` |
| 107 | +- [MapView Insets App](../../microapps/MapViewInsetsApp/README.md) demonstrates the use of `Insets` |
| 108 | +- [SceneView Camera Controller App](../../microapps/SceneViewCameraControllerApp/README.md) demonstrates the use of the `CameraController` |
| 109 | +- [SceneView Lighting Options App](../../microapps/SceneViewLightingOptionsApp/README.md) demonstrates the use of various lighting options with the `SceneView` |
| 110 | + |
| 111 | + |
0 commit comments