Search widget+auto Navigate

1247
9
07-26-2019 10:56 AM
anjelinaponkerat
Occasional Contributor II

I migarate from 4.11 to 4.12, after migration my search widget can not auto navigate to results!! why?

0 Kudos
9 Replies
KellyHutchins
Esri Frequent Contributor

By default autoSelect is enabled and the search will select and zoom to the first geocoded result. It works in the sample: https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=widgets-search...

Do you have a reproducible bit of code that shows what you are seeing?

0 Kudos
anjelinaponkerat
Occasional Contributor II


var searchWidget = new Search({

view: view,

allPlaceholder: "search...",


sources: [{
layer: new FeatureLayer({
url: "localhost:6080/arcgis/rest/services/city/FeatureServer/0",
outFields: ["*"],

}),
searchFields: ["city"],
displayField: "city",
exactMatch: false,
outFields: ["city", "local"],
name: "city1",
placeholder: "search city...",

autoNavigate: true,

maxResults:10,
maxSuggestions:50,

enableSuggestions: true
},

0 Kudos
KellyHutchins
Esri Frequent Contributor

autoNavigate is true by default so you shouldn't have to set it if you want true.  I tested both true and false using this sample and got the expected behavior in both 4.11 and 4.12. 

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=widgets-search...

0 Kudos
anjelinaponkerat
Occasional Contributor II

Hi

I,m working on 3d view, but your sample is on 2d. I tested your code with my sample and can not zoom on results! why?

0 Kudos
anjelinaponkerat
Occasional Contributor II

I think arcgis java script 4.12 has too many bugs!! There is not any solution??

0 Kudos
anjelinaponkerat
Occasional Contributor II

Hi

When I use search widget it return this error in browser console:

[esri.views.3d.state.ViewStateManager] #goTo() Failed to create camera from target, no layerview has been found for the layer

0 Kudos
KellyHutchins
Esri Frequent Contributor

I submitted a bug for this issue to the dev team. At this point I'm not aware of a workaround but if I discover one I'll reply back here and let you know. 

0 Kudos
KellyHutchins
Esri Frequent Contributor

It looks like goTo fails when it is trying to navigate to a graphic that is not in the map. So one potential workaround = if it works for your use case - would be to add the search layers to the map.  Here's an updated example: 

https://codepen.io/kellyhutchins/pen/KOmKdb?editors=1001

RalucaNicola1
Esri Contributor

Like Kelly said, this is a bug on our side and we'll work on a fix for 4.13. In the meantime a possible workaround is to add the layer to the map like Kelly suggested.

0 Kudos