Image overlays can be used to quickly render frequently changing images in a MapView
or SceneView
. For example, you can render real-time sensor data, such as weather, where each static image displayed represents a single frame from the radar satellite image. A user perceives the display of the static images in succession as an animation if the images are displayed at small enough time intervals.
Image overlays and graphics overlays both render above all layers in the map or scene. Image overlays render below any graphics overlays you've added to the view. This order ensures that graphics you want to display won't be obscured by your image overlays. For example, you might want to show graphics representing aircraft on top of image overlays showing the sensor data they are collecting.
Since they are designed for quick display, image overlays do not support the rich processing and rendering capabilities of a raster layer, which still provides the best option for workflows that require static image rendering, analysis, and persistence. See Add raster data for more information about working with raster layers.
Add an image overlay
A map or scene view manages a collection of image overlays. Each ImageOverlay
contains a single ImageFrame
that defines an image to display. Georeferenced images (those with a world file) are added at the correct geographic location. Otherwise, you must define a geographic extent for the image frame. If a spatial reference is not defined for the extent, it is assumed to be the same as the map or scene. If the spatial reference of the extent is different from that of the map or scene, the image will fail to render.
-
If your image doesn't have georeference information, define an extent for the image using an
Envelope
or quadrilateralPolygon
.The following example defines a geographic extent using an envelope defined with a center point, width, and height.
Create envelopeUse dark colors for code blocks Copy // Create an Envelope for displaying the image frame in the correct location. private val pacificSouthwestEnvelope = Envelope( center = pointForImageFrame, width = 15.0958, height = -14.3770 )
You can also define a geographic extent using a polygon that has exactly four points (to define each corner of the image). The polygon can be any quadrilateral; it need not be a rectangle.
Create polygonUse dark colors for code blocks Copy // (untransformed) Lower-left -> Upper-left -> Upper-right -> Lower-right private val pacificSouthwestPolygon = Polygon( listOf( Point(x = -123.000, y = 27.000), Point(x = -123.000, y = 40.000), Point(x = -120.000, y = 40.000), Point(x = -120.000, y = 27.000), ) )
When you define the polygon, the order in which you specify the vertices has significance and can result in rotating or reflecting the image displayed within the polygon.
In the following descriptions, all starting positions refer to the original (untransformed) position.
When specifying vertices in the clockwise direction: Start in the lower-left corner to display the image in its original orientation. Starting at the next clockwise vertex rotates the image 90° clockwise, and so on.
When specifying vertices in the counterclockwise direction: Start in the lower-right corner to reflect the image around the y-axis. Starting at the next counterclockwise vertex rotates the reflected image 90° counterclockwise, and so on.
-
Create an image frame and pass an image into the constructor. You can specify an image with a uri to a local or online source. Supported formats are GeoTIFF, TIFF, JPEG, and PNG. If you need to define the extent explicitly, also pass the envelope or polygon to the constructor.
Create image frame using ArcGIS Maps APIUse dark colors for code blocks Copy // Create an image with the given path and use it to create an image frame val imageFrame = ImageFrame( uri = imageFile.path, extent = pacificSouthwestEnvelope )
Create image frame using Android's BitmapDrawableUse dark colors for code blocks Copy val imageFrame = ImageFrame.createWithImageAndExtent( image = bitmapDrawable, extent = pacificSouthwestEnvelope )
-
Attach the initial image frame to the image overlay. The image overlay has properties to control visibility and opacity of the image. Set the opacity less than 1.0 to make the image semi-transparent so data underneath can be seen.
Add image frame to an image overlayUse dark colors for code blocks Copy var imageOverlay = ImageOverlay() // Attach the initial image frame to the image overlay. imageOverlay.imageFrame = imageFrames[0] imageOverlay.opacity = 0.5f
-
Add the image overlay to the map or scene view's image overlay collection. To zoom to the extent of the image, you can set the viewpoint using the image frame extent.
Add image overlay to scene view's image overlay collectionUse dark colors for code blocks Copy // Add image overlay to scene view's image overlays SceneView( modifier = Modifier .fillMaxSize(), arcGISScene = scene, imageOverlays = listOf(imageOverlay) )
Set viewpoint with the image frame's extentUse dark colors for code blocks Copy scene.initialViewpoint = imageFrames[0].extent?.let { extent -> Viewpoint( boundingGeometry = extent, camera = camera ) }

Animate an image overlay
You can animate the display of image overlays by changing the frame they contain at a specified interval. You might use a timer, for example, to read the next image in a sequence, use it to create a new ImageFrame
, and replace the current frame in the ImageOverlay
.
-
Create a collection of images frames in the correct sequence. The images in the image frames may be added explicitly, read from a local folder, downloaded from a service, or perhaps read from a shared location that is periodically updated with new data.
The example below creates image frames and adds them to a collection.
Create list of image framesUse dark colors for code blocks Copy // Get the image files from local storage and iterate over the files. // For each file, create an image frame, and add it to imageFrames list. (File(filePath).listFiles())?.sorted()?.forEach { imageFile -> // Create an image with the given path and use it to create an image frame val imageFrame = ImageFrame( uri = imageFile.path, extent = pacificSouthwestEnvelope ) imageFrames.add(imageFrame) }
-
Create a new timer and set it to call a function to change the image at the desired interval.
Create a timerUse dark colors for code blocks Copy // Get the current period from the fps state flow val period = when (_fps.value) { 60 -> 17 // 1000ms/17 = 60 fps 30 -> 33 // 1000ms/33 = 30 fps 15 -> 67 // 1000ms/67 = 15 fps else -> 0 } // Cancel any timers that might be running timer?.cancel() timer = null // Create a new timer with the given period timer = kotlin.concurrent.fixedRateTimer("Image overlay timer", period = period.toLong()) { addNextImageFrameToImageOverlay() }
-
For each timer interval, replace the current image frame in the overlay with the next image frame from the collection.
The following example changes the image in the overlay while keeping the image at the same spatial extent. If required by your workflow, you could also animate the overlay location by changing the image frame's extent.
Add next frame to image overlayUse dark colors for code blocks Copy private var imageFrameIndex = 0 private fun addNextImageFrameToImageOverlay() { // Set image frame to image overlay imageOverlay.imageFrame = imageFrames[imageFrameIndex] // Increment the index to keep track of which image to load next imageFrameIndex++ // Reset index once all files have been loaded if (imageFrameIndex == imageFrames.size) imageFrameIndex = 0 }