Skip to content

Compose doc improvements #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ import kotlinx.coroutines.launch
* @param onTwoPointerTap lambda invoked when a user taps two pointers on the composable MapView
* @param onPan lambda invoked when a user drags a pointer or pointers across composable MapView
* @param onDrawStatusChanged lambda invoked when the draw status of the composable MapView is changed
* @sample com.arcgismaps.toolkit.geocompose.samples.MapViewSample
* @see
* - <a href="https://developers.arcgis.com/kotlin/maps-2d/tutorials/display-a-map/">Display a map tutorial</a>
* - <a href="https://developers.arcgis.com/kotlin/maps-2d/tutorials/display-a-web-map/">Display a web map tutorial</a>
* - <a href="https://developers.arcgis.com/kotlin/maps-2d/tutorials/add-a-point-line-and-polygon/">Add a point, line, and polygon tutorial</a>
* @since 200.4.0
*/
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ import java.time.Instant
* @param onTwoPointerTap lambda invoked when a user taps two pointers on the composable SceneView
* @param onPan lambda invoked when a user drags a pointer or pointers across composable SceneView
* @param onDrawStatusChanged lambda invoked when the draw status of the composable SceneView is changed
* @sample com.arcgismaps.toolkit.geocompose.samples.SceneViewSample
* @see
* - <a href="https://developers.arcgis.com/kotlin/scenes-3d/tutorials/display-a-scene/">Display a scene tutorial</a>
* - <a href="https://developers.arcgis.com/kotlin/scenes-3d/tutorials/display-a-web-scene/">Display a web scene tutorial</a>
* @since 200.4.0
*/
@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package com.arcgismaps.toolkit.geocompose.samples

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.arcgismaps.Color
import com.arcgismaps.data.ServiceFeatureTable
import com.arcgismaps.geometry.Point
import com.arcgismaps.geometry.SpatialReference
import com.arcgismaps.mapping.ArcGISMap
import com.arcgismaps.mapping.ArcGISScene
import com.arcgismaps.mapping.ArcGISTiledElevationSource
import com.arcgismaps.mapping.BasemapStyle
import com.arcgismaps.mapping.Surface
import com.arcgismaps.mapping.Viewpoint
import com.arcgismaps.mapping.layers.FeatureLayer
import com.arcgismaps.mapping.symbology.SimpleLineSymbol
import com.arcgismaps.mapping.symbology.SimpleLineSymbolStyle
import com.arcgismaps.mapping.symbology.SimpleRenderer
import com.arcgismaps.mapping.view.Camera
import com.arcgismaps.toolkit.geocompose.MapView
import com.arcgismaps.toolkit.geocompose.SceneView

/**
* @suppress Suppress this function from being indexed in the KDoc
*/
@Composable
public fun SceneViewSample() {
// Display a SceneView with an elevation surface and an initial viewpoint

// add base surface for elevation data
val elevationSource = ArcGISTiledElevationSource(
uri = "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"
)
val surface = Surface().apply {
elevationSources.add(elevationSource)
// add an exaggeration factor to increase the 3D effect of the elevation.
elevationExaggeration = 2.5f
}

val cameraLocation = Point(
x = -118.794,
y = 33.909,
z = 5330.0,
spatialReference = SpatialReference.wgs84()
)

val camera = Camera(
locationPoint = cameraLocation,
heading = 355.0,
pitch = 72.0,
roll = 0.0
)

// display the Composable SceneView
SceneView(
modifier = Modifier.fillMaxSize(),
arcGISScene = ArcGISScene(BasemapStyle.ArcGISImagery).apply {
baseSurface = surface
initialViewpoint = Viewpoint(cameraLocation, camera)
}
)
}


/**
* @suppress Suppress this function from being indexed in the KDoc
*/
@Composable
public fun MapViewSample() {
// Display a feature layer MapView using a service feature table

// map used to display a feature layer
val map = ArcGISMap(BasemapStyle.ArcGISTopographic).apply {
initialViewpoint = Viewpoint( // USA viewpoint
center = Point(-11e6, 5e6, SpatialReference.webMercator()),
scale = 1e8
)
}

// create a service feature table and a feature layer from it
val serviceFeatureTable = ServiceFeatureTable(
uri = "https://services.arcgis.com/jIL9msH9OI208GCb/arcgis/rest/services/USA_Daytime_Population_2016/FeatureServer/0"
)

// create the feature layer using the service feature table
val featureLayer: FeatureLayer = FeatureLayer.createWithFeatureTable(serviceFeatureTable)

// use symbol to show U.S. states with a black outline
val lineSymbol = SimpleLineSymbol(
style = SimpleLineSymbolStyle.Solid,
color = Color.black,
width = 1.0f
)

// set feature layer properties
featureLayer.apply {
// set renderer for the feature layer
renderer = SimpleRenderer(lineSymbol)
opacity = 0.8f
maxScale = 10000.0
}
// add the feature layer to the map's operational layers
map.operationalLayers.add(featureLayer)

// display the Composable MapView
MapView(
modifier = Modifier.fillMaxSize(),
arcGISMap = map
)
}