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.
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");
})
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?
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");
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.
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.
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!
According to this page, this is resolved in the upcoming 4.28 release; search (Ctrl-F) for "Esri Community - 1308220".