Overlapping Graphics

609
1
05-30-2018 10:09 AM
VishnuB
New Contributor III

When two polygon graphics in a GraphicsOverlay overlaps, the graphics which is lying on the top gets covered and the graphics which is in bottom is not visible. The opacity of the GraphicsOverlay is set to 0.2. If the graphics are in different GraphicsOverlay both the graphics are visible and the overlapped part become darker. Is there any way to achieve this if the graphics are in same GraphicsOverlay?

0 Kudos
1 Reply
LucasDanzinger
Esri Frequent Contributor

Yes. Instead of applying opacity on the GraphicsOverlay, apply an alpha value to the color of your symbol. For example, the below code gives me this result:

// add a mapView component
MapView {
    anchors.fill: parent
    // set focus to enable keyboard navigation
    focus: true

    // add a map to the mapview
    Map {
        // add the BasemapTopographic basemap to the map
        BasemapTopographic {}
    }

    GraphicsOverlay {
        Graphic {
            Point {
                x: -20
                y: 0
                spatialReference: SpatialReference {wkid: 4326}
            }
            SimpleMarkerSymbol {
                size: 120
                color: Qt.rgba(1,0,0,0.5) // this is the key part - set alpha value when defining color
            }
        }

        Graphic {
            Point {
                x: 20
                y: 0
                spatialReference: SpatialReference {wkid: 4326}
            }
            SimpleMarkerSymbol{
                size: 120
                color: Qt.rgba(1,0,0,0.5)
            }
        }
    }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍