AnsweredAssumed Answered

Add a feature

Question asked by glalla_uwi2017 on Nov 1, 2018
Latest reply on Nov 2, 2018 by NManocha-esristaff

Hi,

I am trying to add a feature as soon as an app is opened. I tried the code below but it is not working. The location is turning on however, the feature is not showing up. How can I fix this?

 

       Component.onCompleted: {
            //Qt.openUrlExternally("%1/home/webmap/viewer.html?webmap=%2".arg(app.portalUrl).arg(portalItem.id))
            if (!mapView.locationDisplay.started) {
                mapView.locationDisplay.start()
                mapView.locationDisplay.autoPanMode = Enums.LocationDisplayAutoPanModeRecenter
                    // create attributes json for the new feature
                    var featureAttributes = {"xxxx" : "xxxx"};
                    // create a new feature using the mouse's map point
                    var point = mapView.locationDisplay.mapLocation
                    var feature = featureTable.createFeatureWithAttributes(featureAttributes, point);
                    // add the new feature to the feature table
                    featureTable.addFeature(feature);
            } else {
                mapView.locationDisplay.stop()
            }
        }

Outcomes