Select to view content in your preferred language

KML Overlay Swipe Layer Right to Left

429
2
10-09-2019 01:26 PM
MKa
by
Frequent Contributor

I have been working with the KMLGroundOverlay sample and it has helped me a lot to get all of my image overlaid on my map.  But now I want to incorporate a Swipe Layer slider instead for the color slider like is done in the below sample.  Instead of changing the opacity of the top most layer, I want it to hide the layer from right to left.  This is done a lot with time images, so you can see what was there before.  How do I mask the topmost layer from right to left according to the percent value on the slider?

MapView {
                id: sceneView
                anchors.fill: parent

                Rectangle {
                    anchors.fill: slider
                    radius: 5
                }

                Slider {
                    id: slider
                    anchors {
                        left: parent.left
                        top: parent.top
                        margins: 10
                    }
                    from: 0
                    to: 1
                    value: 1
                    stepSize: 0.1
                    onValueChanged: {
                        // I WANT TO HIDE THE OVERLAY FROM RIGHT TO LEFT BASED ON VALUE
                        groundOverlay.color = Qt.rgba(0, 0, 0, value);

                    }
                }

                Map {
                    BasemapImagery {}

                    // Create a KML Layer
                    KmlLayer {
                        id: kmlLayer
                        // Create a KML Dataset
                        KmlDataset {
                            // Create a Ground Overlay by assigning an icon and geometry
                            KmlGroundOverlay {
                                id: groundOverlay
                                rotation: -3.046024799346924

                                KmlIcon {
                                    url: "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Qt_logo_2016.svg/1200px-Qt_logo_2016.svg.png"
                                }

                                Envelope {
                                    id: env
                                    xMin: -123.066227926904
                                    yMin: 44.04736963555683
                                    xMax: -123.0796942287304
                                    yMax: 44.03878298600624
                                    SpatialReference {
                                        wkid: 4326
                                    }
                                }
                            }
                        }

                        // set viewpoint to the ground overlay
                        onLoadStatusChanged: {
                            if (loadStatus !== Enums.LoadStatusLoaded)
                                return;

                            const vp = ArcGISRuntimeEnvironment.createObject("ViewpointCenter", {
                                                                                 center: env.center,
                                                                                 targetScale: 10000
                                                                             });
                            sceneView.setViewpoint(vp);
                        }
                    }
                }
            }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
2 Replies
LucasDanzinger
Esri Frequent Contributor

We don't have API to support this at the moment. Not sure if there is a workaround of some sort. Could you change opacity with a slider instead?

0 Kudos
MKa
by
Frequent Contributor

The opacity doesn't work for what we need.  We need to examine a layer by visualizing the difference between one layer for say "Day 1" and the same layer on "Day 10".  The slider allows me to move the layer back and forth.  Opacity doesn't work very well with this as the layers are essentially heat maps, and by changing opacity the value of the Heat map doesn't work very well.

I know you can just turn the layer off and on and examine the differences, My layers are on a hidden popup, so it wouldn't work very well to turn them off and on.

I am thinking about making just a quick  button that when pressed, will turn off the topmost layer.  Then when you release it will go back to on.  This will allow a user to see the differences easily by the naked eye.

0 Kudos