The screenshot in my previous post was grabbed from running it in a desktop Java Runtime app which was for convenience.
I does however work on in my Kotlin Android app too. This is the modified onCreate method from my app:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// create the service feature table
val serviceFeatureTable = ServiceFeatureTable("https://hbsyb.booway.com.cn/arcgis/rest/services/zjsxyd/sichuanxianjixingzhengqu/MapServer/0");
// create the feature layer using the service feature table
val featureLayer = FeatureLayer(serviceFeatureTable)
// create a map with the terrain with labels basemap
ArcGISMap(Basemap.createTerrainWithLabels()).let { map ->
// set an initial viewpoint
//map.initialViewpoint = Viewpoint(
// Point(
// -13176752.0,
// 4090404.0,
// SpatialReferences.getWebMercator()
// ), 500000.0
//)
// add the feature layer to the map
map.operationalLayers.add(featureLayer)
featureLayer.loadAsync()
featureLayer.addDoneLoadingListener {
val extent: Envelope = featureLayer.getFullExtent()
mapView.setViewpointGeometryAsync(extent)
}
// set the map to be displayed in the mapview
mapView.map = map
}
}
This zooms to the extent of the layer once it is loaded and on my Samsung phone looks like this:
If you use my code, does this work for you?