In earlier chapters, we discussed overlays in a limited manner. But now, it's time to go a little deeper into the subject. Overlays allow you to add .NET FrameworkElement
to a collection called OverlayItemsCollection
. For example, the following code can be used to add TextBlock
over San Francisco:
var tb = new TextBlock(); tb.Foreground = new SolidColorBrush(Colors.Red); tb.FontWeight = FontWeights.Bold; tb.Background = new SolidColorBrush(Colors.White); tb.Height = 20; tb.Text = "San Francisco"; var geoPoint = new Esri.ArcGISRuntime.Geometry.MapPoint(-122.44, 37.8, Esri.ArcGISRuntime.Geometry.SpatialReferences.Wgs84); this.mapView.Overlays.Items.Add(tb); Esri.ArcGISRuntime.Controls.MapView.SetViewOverlayAnchor(tb, geoPoint);
See here:
A TextBlock
component such as this adds a little context to the map, but you can go way beyond that because you can add pretty much anything into the Overlays
collection. Typically, however, overlays are added to...