Select to view content in your preferred language

SearchWidget with view:no-layerview-for-layer issue in 4.27.x version

2581
6
07-14-2023 04:58 AM
mukecz1
New Contributor II

Hi,

I have encountered a peculiar issue while working on the SearchWidget. I used the following code to create the widget, and on the surface, it seems to be functioning properly - it zooms into the searched area with graphic and popup.

However, an error message appears in the console stating, 'view:no-layerview-for-layer No layerview has been found for the layer.' It seems that the issue relates to the feature layer in the search source.

I'm not sure if it's a bug or not.

Thank you in advance for your assistance.

 

 

mukecz1_0-1689335678537.png

 

 

 

  await mapView.when(async () => {
searchStores.value.forEach((s) => {
      searchSources.push({
        layer: new FeatureLayer({
          url: s.url,
          popupTemplate: {
            title: s.title,
            overwriteActions: true,
          },
        }),
        suggestionTemplate: s.suggestionTemplate,
        searchFields: s.searchFields,
        displayField: s.displayField,
        maxSuggestions: s.maxSuggestions,
        maxResults: s.maxResults,
        exactMatch: s.exactMatch,
        outFields: s.outFields,
        name: s.name,
        placeholder: s.placeholder
      });
    });

    const searchWidget = new Search({
      view: mapView,
      allPlaceholder: "Searching",
      includeDefaultSources: false,
      sources: searchSources
    });
    mapView.ui.add(searchWidget, "top-right");
})

 

 

 

6 Replies
Noah-Sager
Esri Regular Contributor

Hi @mukecz1, thanks for posting your question here. I think the issue is related to the featureLayer being created on the fly. I see that the error is thrown in the console, but the Search widget seems to work fine. Can you try creating the layer in a separate function, and then pushing each layer source?

mukecz1
New Contributor II

Hi @Noah-Sager , thanks for advice,

I did try something like this, but the error still displays in the console.

I can confirm it happens since v4.27.0, I don't have this issue in v4.26.x.

From the error in the console, it seems to be from the PopupViewModel. Could this be related to the popup changes in v4.27?

 

 

 

   let l =  new FeatureLayer({
      url: URL,
      popupTemplate: {
        title:"Coupe {PROVCOUPE}",
        overwriteActions: true,
      },
    });
    searchSources.push({
      layer:l,
      suggestionTemplate: "{PROVCOUPE}",
      searchFields:["PROVCOUPE"],
      displayField: "PROVCOUPE",
      maxSuggestions: 6,
      maxResults: 6,
      exactMatch: false,
      outFields: ["PROVCOUPE"],
      name:"Provcoupe",
      placeholder:"example:XXX"
    });
    const searchWidget = new Search({
      view: mapView,
      allPlaceholder: "Searching",
      includeDefaultSources: false,
      sources: searchSources
    });
    mapView.ui.add(searchWidget, "top-right");

 

 

 

 

0 Kudos
Noah-Sager
Esri Regular Contributor

Hey @mukecz1, that's good sleuthing. The popup is indeed related. Looks like a legit bug. We'll get to work on it, and I'll update this post when we have an update to share.

JoelBennett
MVP Regular Contributor

The PopupViewModel is attempting to highlight the feature on the map, but since the layer isn't added to the map, the process fails.  If you set the highlightEnabled property on the Popup to false, you'll likely notice the error doesn't happen.  However, the Popup will then not highlight features on any layer.

I don't know if this meets the technical definition for a bug, but it could perhaps be handled more gracefully.  After all, in looking at the documentation for the Search widget's resultGraphic property, it seems the intent is to still enable highlighting for all results.

0 Kudos
MichaelS1
New Contributor II

Hi everyone,

I’m encountering an issue when using "new Search" with the “new FeatureLayer” in the ReactJS library. Can anyone confirm if this bug has been resolved? Any help would be greatly appreciated. Thanks!

0 Kudos
JoelBennett
MVP Regular Contributor

According to this page, this is resolved in the upcoming 4.28 release; search (Ctrl-F) for "Esri Community - 1308220".