A graphics overlay is a container for temporary graphics that you want to display on your map view or scene view, such as the graphics in the following illustration. The graphics you draw in your graphics overlays are created at run time and are not persisted when your application closes.
Typical use cases for adding graphic overlays to your map view or scene view include the following:
- Showing the location of a moving object. The locations could be from your own GPS receiver
- Showing the results of a geocoding or routing task
- Drawing temporary map markups, sometimes referred to as red lining
A map view or scene view can contain many graphics overlays that are drawn on top of the layers in your map or scene. Each graphics overlay may contain a number of graphics. A graphic is defined by the following components:
- Geometry, which is either a point, line, or polygon
- Symbology, which defines how your geometry is drawn. For example, if the geometry is a line, then your symbology would define the line color as red
- Attributes, which are an optional set of item fields in a database row
// find QML MapView component
m_mapView = findChild<MapQuickView*>("mapView");
// Create a map using the oceans basemap
m_map = new Map(BasemapType::Oceans, 56.075844, -2.681572, 11, this);
// set map on the map view
// create a new graphics overlay
GraphicsOverlay* graphicsOverlay = new GraphicsOverlay(this);
// add the overlay to the mapview
Now you're ready to add graphics and text to your graphics overlays.
Graphics overlays are visible only on a map view which contains a map, or a scene view which contains a scene. Graphics overlays do not have a time extent and do not participate in time-based filtering when a time extent is set on a map view or scene view.