View on GitHub Sample viewer app

Determine the map’s load status which can be: NotLoaded, FailedToLoad, Loading, Loaded.

Image of monitor changes to map load status

Use case

Knowing the map’s load state may be required before subsequent actions can be executed.

How to use the sample

Click on the button to reload the ArcGISMap. The load status of the ArcGISMap will be displayed on screen.

How it works

The LoadStatus is Loaded when any of the following criteria are met:

  • The map has a valid spatial reference.
  • The map has an an initial viewpoint.
  • One of the map’s predefined layers has been created.

Relevant API

  • ArcGISMap
  • LoadStatus StateFlow
  • MapView

Tags

load status, loadable pattern, map

Sample Code

MainActivity.kt MainActivity.kt MonitorChangesToMapLoadStatusViewModel.kt MonitorChangesToMapLoadStatusScreen.kt
/* Copyright 2025 Esri
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.esri.arcgismaps.sample.monitorchangestomaploadstatus
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import com.arcgismaps.ApiKey
import com.arcgismaps.ArcGISEnvironment
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
import com.esri.arcgismaps.sample.monitorchangestomaploadstatus.screens.MonitorChangesToMapLoadStatusScreen
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// authentication with an API key or named user is
// required to access basemaps and other location services
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.ACCESS_TOKEN)
setContent {
SampleAppTheme {
MonitorChangesToMapLoadStatusApp()
}
}
}
@Composable
private fun MonitorChangesToMapLoadStatusApp() {
Surface(color = MaterialTheme.colorScheme.background) {
MonitorChangesToMapLoadStatusScreen(
sampleName = getString(R.string.monitor_changes_to_map_load_status_app_name)
)
}
}
}