Select to view content in your preferred language

Strange behaviour of identifyLayers method

1151
5
06-21-2023 06:07 AM
GKmieliauskas
Esri Regular Contributor

I have application running ArcGIS Runtime 100.15. My application has some feature service layers. I am trying to identify features on mouse click. Sometimes it works, sometimes is not. identifyLayers or identifyLayersWithMaxResults methods from MapView does not generate IdentifyLayersStatusChanged event. I have a timer in my app and after 1 minute application hides busy indicator.

It stops somewhere in the code of these methods. I have tried to use Fiddler to check how request are moving but without success. Code stops working after first feature service layer or before first layer. Layer is not the same each time. It could depend on map scale because I am work with visible layers only. There is more than one visible layer always.

Usually it does not work at all after first unsuccessful identify. But I have some success after I try to move or scale map.

These feature service layers are public.

0 Kudos
5 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

 

Can you share your code showing how you create/initialize the feature layers and how you have implemented the identify?

 

Thanks

0 Kudos
GKmieliauskas
Esri Regular Contributor

Hi @MichaelBranscomb ,

I have added some separate pieces of my code.

Creating feature layer:

                function addSubLayer(featureServiceLayerUrl, lyrid, container) {
                    let sublayerurl = featureServiceLayerUrl + "/" + lyrid

                    let serviceFeatureTable = ArcGISRuntimeEnvironment.createObject("ServiceFeatureTable", {url: sublayerurl});
                    let customLayer = ArcGISRuntimeEnvironment.createObject("FeatureLayer", {featureTable: serviceFeatureTable,spatialReference: Factory.SpatialReference.createWebMercator()});

                    customLayer.layerId = lyrid

                    container.append(customLayer)
                    if (customLayer.loadStatus !== Enums.LoadStatusLoaded) {
                        customLayer.loadStatusChanged.connect(function(){
                            if (customLayer.loadStatus === Enums.LoadStatusLoaded){
                                // 
                            }
                        })
                        customLayer.load()
                    }
                    else {
                        // 
                    }
                }

Identifying part:

            onMouseClicked: {
                if(panelDockItem.visible) return
                if(identifyInProgress) return

                if (mapView.map.loadStatus === Enums.LoadStatusLoaded) {
                    mapView.populateVisibleLayers()

                    // store the selected buffer point
                    mapView.selectedBufferPoint = mouse.mapPoint

                    busyIndicatorText.text = strings.kIdentifying
                    busyIndicator.visible=true

                    //console.debug("identifyFeatures")

                    identifyInProgress = true
                    identifyFeatures (mouse.x, mouse.y, mapView.bufferDistance, mapView.measureUnits)
                }
            }

            function identifyFeatures (x, y, bufferRadius, measurementUnits, returnPopupsOnly, maxResults) {
                //console.debug("cancelAllTasks")
                cancelAllTasks()
                //if (typeof tolerance === "undefined") tolerance = 10
                if (typeof returnPopupsOnly === "undefined") returnPopupsOnly = false
                if (typeof maxResults === "undefined") maxResults = 10

                mapView.featuresModel.clearAll();
                mapView.layerResults=[];
                mapView.identifyProperties.reset();

                mapView.featuresModel.searchMode = searchMode.spatial;

                var id = mapView.identifyLayersWithMaxResults(x, y, 22, returnPopupsOnly, maxResults)
                //var id = mapView.identifyLayers(x, y, 10, returnPopupsOnly)

                console.debug("Tasks ID: %1".arg(id))
                mapView.tasksInProgress.push(id)

                spatialQueryTimer.currentTaskId = id;
                spatialQueryTimer.start();
            }

 

0 Kudos
Tanner_Yould
Esri Contributor

Hi Gintautas, it's difficult to pin down what exactly may be happening here with the code you've provided. Perhaps `identifyInProgress` is not being reset after a failed query and that's why you can't start a new query if it fails. Something may also be taking focus away from MapView so mouse clicks aren't propagating to that? 

We have some sample code that demonstrates how to identify layers that you may find useful to compare against: https://developers.arcgis.com/qt/qml/sample-code/identify-layers/

I know it's not much, but I hope this helps!

Tanner Yould
Product Engineer
ArcGIS Maps SDK for Native Apps
Esri
0 Kudos
GKmieliauskas
Esri Regular Contributor

Hi @Tanner_Yould ,

I will try to make simple application according to your suggested sample with our data and inform about testing results

0 Kudos
GKmieliauskas
Esri Regular Contributor

Hi @Tanner_Yould , @MichaelBranscomb ,

Sorry for long delay. Took time to get to the root of the issue.

We have found why identify works so long on our project. We have few layers from Feature service. Some of them has symbology dependent on field value and one layer has transparent symbol because symbology is included in basemap. So, we need that layer for identify only. Identify of 3 layers lasts less than second, identify on layer with transparent symbols may take more than half minute. We have checked on ArcGIS Pro. It works similar. If symbol has transparent filling but visible border, identify works on border line only. Clicking inside transparent symbol filling stops identify process.

0 Kudos