Image overlays can be used to quickly render frequently changing images in a map view or scene view. 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
.Use dark colors for code blocks Copy // Create an envelope for displaying the image frame in the correct location. var centerPoint = new MapPoint(-120.0724, 35.1310, SpatialReferences.Wgs84); var pacificSouthwestEnvelope = new Envelope(center:centerPoint, width:15.0958, height:14.3770); // Project the envelope to the spatial reference of the geoview (map or scene view). var projectedEnvelope = (Envelope)GeometryEngine.Project(pacificSouthwestEnvelope, MyGeoView.SpatialReference);
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.
Use dark colors for code blocks Copy var lowerLeftPt = new MapPoint(-127.6203, 27.9425, SpatialReferences.Wgs84); var upperLeftPt = new MapPoint(-127.6203, 42.3195, SpatialReferences.Wgs84); var upperRightPt = new MapPoint(-112.5245, 42.3195, SpatialReferences.Wgs84); var lowerRightPt = new MapPoint(-112.5245, 27.9425, SpatialReferences.Wgs84); // Define a polygon with vertices clockwise from the lower left. var pacificSouthwestPolygon = new Polygon( [ lowerLeftPt, upperLeftPt, upperRightPt, lowerRightPt ], SpatialReferences.Wgs84); // Project the polygon to the spatial reference of the geoview. var projectedPolygon = (Polygon)GeometryEngine.Project(pacificSouthwestPolygon, MyGeoView.SpatialReference);
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 TIFF, GeoTIFF, ICO, BMP, GIF, JPEG, and PNG. Animated GIF is not supported. If you need to define the extent explicitly, also pass the envelope or polygon to the constructor.Use dark colors for code blocks Copy // Get all .png files in a directory (weather radar images, for example). var imagePaths = Directory.GetFiles(imageFolder, "*.png"); // Create an image frame with a path (URI) to an image file and the extent envelope. var firstImageUri = new System.Uri(imagePaths.FirstOrDefault()); var imageFrame = new ImageFrame(firstImageUri, projectedEnvelope);
Use dark colors for code blocks Copy // Create an image using a path to a local png file, then create an image frame. var image = new RuntimeImage(firstImageUri); imageFrame = new ImageFrame(image, projectedEnvelope);
-
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.
Use dark colors for code blocks Copy // Add the image frame to an image overlay and set it to be 50% transparent. var imageOverlay = new ImageOverlay(imageFrame); imageOverlay.Opacity = 0.5;
-
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.
Use dark colors for code blocks Copy // Add the image overlay to the geoview's image overlay collection. MyGeoView.ImageOverlays.Add(imageOverlay);

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.
Use dark colors for code blocks Copy // Get all .png files in the image folder. string[] imagePaths = Directory.GetFiles(imageFolder, "*.png"); // Sort the file paths alphabetically (for images named with a timestamp). Array.Sort(imagePaths); // Create an image frame for each image using the filepath and extent envelope. _images = imagePaths.Select(path => new ImageFrame(new Uri(path), projectedEnvelope)).ToArray();
-
Create a new timer and set it to call a function to change the image at the desired interval.
Use dark colors for code blocks Copy // Create new timer that will call a function that updates images every 50 milliseconds. _timer = new Timer(AnimateOverlay); _timer.Change(0, 50);
-
For each timer interval, replace the current image frame in the overlay with the next image frame from the collection.
Use dark colors for code blocks Copy // If the animation is stopped, do not update the image overlay. if (!_animationStopped) { // Set the image overlay to display the next frame. _imageOverlay.ImageFrame = _images[_imageIndex]; // Increase the index of the image. _imageIndex = (_imageIndex + 1) % _images.Length; }