u.load is not a function

715
4
02-07-2023 07:33 PM
LazyDogz
New Contributor II

Sorry for my bad english. Every time I run the project, this error always appears, and when I refresh the page, it disappears. It's very annoying because every time it happens, I have to continuously refresh the page.

image.png
here is my code in Search:

view.when(() => {

const searchWidget = new Search({
view: view,
sources: [
{
layer: fl,
searchFields: ["Name", "Address"],
name: "Search",
zoomScale: 10000,
},
],
includeDefaultSources: false,
allPlaceholder: "Tìm kiếm địa điểm",
});

const expandSearch = new Expand({
view: view,
content: searchWidget,
expandTooltip: "Search",
});
view.ui.add(expandSearch, {
position: "top-left",
});

I will be grateful for any help you can provide.

Tags (1)
0 Kudos
4 Replies
ReneRubalcava
Frequent Contributor

If you can provide a sample in codepen or similar, it would help. Could be the layer, but no way to tell.

https://codepen.io/

0 Kudos
LazyDogz
New Contributor II

Here is my code look like: https://codepen.io/nhannt2909/pen/dyjEEoW 

0 Kudos
ReneRubalcava
Frequent Contributor

There is a lot going on in that sample, but if I had to guess, it's because you are calling the result of your ajax request "fl", and calling the FeatureLayer "fl", shadowing the variables. That's just a guess, the sample doesn't run as-is due to some other issues.

0 Kudos
LazyDogz
New Contributor II

I guess the same as you. Is there any way to fix that error?

0 Kudos