hey im trying to use a search widget, with the ESRI JS API 4. the source im using is a layer in the webmap.
using the layer (find by name) is painfully slow but it only have 250 features. adding the layer as a feature layer to the webmap(instead of an item) solves the problem but then its not grouped and is above relevant layers.
am i using the widget wrong? can i do anything to better the search time?
if not- is there a way to move feature layers under items in the webmap?
can i group the layer myself?(the other layer grouped is huge and wont draw fully as a featureLayer so i want to group it as a mapImageLayer while keeping the source as a feature layer) heres the code i use:
import Layer from "@arcgis/core/layers/Layer";
import MapView from "@arcgis/core/views/MapView";
import Search from "@arcgis/core/widgets/Search";
export default function AddSearchWidget(view: MapView, layer: Layer) {
const source = {
name: "river status",
layer: layer,
searchFields: ["label"],
displayField: "label",
exactMatch: false,
outFields: ["label"],
placeholder: "For example: Nile river"
};
const searchWidget = new Search({
view: view,
//activeSourceIndex:-1,
allPlaceholder: "address river name",
sources: [source]
});
// Adds the search widget below other elements in
// the top left corner of the view
view.ui.add(searchWidget, {
position: "top-right",
index: 2
});
}