Cant identify on Feature Layer

561
5
06-10-2019 10:07 AM
jaykapalczynski
Frequent Contributor

I am using the Web Map template in AppStudio.  The third sample in this template is "We Map Identify"

I update the MAP section as seen below but the feature layer does not identify....Am I missing something????

In this .qml file is this code that seems to allow for the identify of a Feature Layer.

        // Signal handler for identify
        onIdentifyLayersStatusChanged: {
            if (identifyLayersStatus === Enums.TaskStatusCompleted) {

//SNIP OUT ALL THE CODE ABOVE TO MAKE SHORTER

                    }else{
                        // Results are from Feature Layer
                        // iterate through individual features of the feature Layer results
                        for(var f = 0; f < identifyLayerResult.popups.length; f++){
                            popup = identifyLayerResult.popups[f];
                            selectedFeature = popup.geoElement;
                            popupDef = popup.popupDefinition;
                            // Appending the result to the model                            
                            newPopup = ArcGISRuntimeEnvironment.createObject("Popup", {
                                                                                 initGeoElement: selectedFeature,
                                                                                 initPopupDefinition: popupDef
                                                                             });

                            // create a popup manager
                            newPopupManager = ArcGISRuntimeEnvironment.createObject("PopupManager", {popup: newPopup});
                            popupListModel.append({'popupManager': newPopupManager});
                        }
                    }

                }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I updated the MAP section to this

        Map{
            initUrl: "http://arcgis.com/sharing/rest/content/items/8ccfcc3a83d241ce9765ff4aea459617"
            //initUrl: "https://vafwisdev.dgif.virginia.gov/arcgis/rest/services/DGIF_Test/BoatRampFacilities/FeatureServer/0"

            FeatureLayer {
                ServiceFeatureTable {
                   url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/0"
                   //featureRequestMode: Enums.FeatureRequestModeOnInteractionNoCache
                }
            }
            onLoadErrorChanged:{
                console.log(mapView.map.loadError.additionalMessage)
            }
        }
0 Kudos
5 Replies
jaykapalczynski
Frequent Contributor

or better yet....using a basemap and the feature layer....still cant identify.....anyone have any thoughts?

        Map{
            BasemapTopographic {}

            FeatureLayer {
                ServiceFeatureTable {
                   url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/0"
                   //featureRequestMode: Enums.FeatureRequestModeOnInteractionNoCache
                }
            }
            onLoadErrorChanged:{
                console.log(mapView.map.loadError.additionalMessage)
            }
        }
0 Kudos
jaykapalczynski
Frequent Contributor

Is there an identify on a Feature Layer Example?  Can I do this?

0 Kudos
nakulmanocha
Esri Regular Contributor

Yes. Webmap sample lets you identify layers within the webmap which can feature layer of map image layer.

It appears to me what you are looking to do is to identify feature layer within a map (not webmap). If yes, then here is a sample available from ArcGIS Runtime Qt/QML team works pretty much the same way, just you need to see if you are identifying a layer or a sublayer.

https://github.com/Esri/arcgis-runtime-samples-qt/blob/master/ArcGISRuntimeSDKQt_QMLSamples/Maps/Ide...

I hope this helps.

Nakul

0 Kudos
jaykapalczynski
Frequent Contributor

Thanks...my main issue is getting at the other attributes....  I cant seem to get to them....I tried 3 or 4 opther ways but keep getting Error: Undefined.

            // loop through the results
            var results = mapView.identifyLayersResults;
            for (var i = 0; i < results.length; i++) {
                var result = results;
                var count = geoElementsCountFromResult(result);
                var layerName = result.layerContent.name;
                var etst = result.attributes.attributeValue("inspector");


0 Kudos
nakulmanocha
Esri Regular Contributor

In your case, result is of type IdentifyLayerResult. IdentifyLayerResult doesn't have a property called attributes. You need to get to the geoElements first. And then read the attributes from the specific geoElement using the attributes property which will return you the AttributeListModel. You also need to check if the IdentifyLayerResult has any sublayers if you happen to have the MapImageLayer instead of a Feature Layer.

https://developers.arcgis.com/qt/latest/qml/api-reference/qml-esri-arcgisruntime-identifylayerresult...

https://developers.arcgis.com/qt/latest/qml/api-reference/qml-esri-arcgisruntime-feature.html#attrib...

0 Kudos