I'm stuck for a while on how to override the default go-to-option in the search widget.
I have to override the default go-to-option, as it results in polygons stuck to the frame of the screen. I managed to write a custom function, which creates a small buffer around the default-extent, see line 209 to 236in my sample. This would work, except that this way, first the default go-to is invoked and only after that has finished, my function is invoked.
then I tried to pass my function as callback and failed (probably because I'm not experienced).
Finally I discovered the goToOverride-property https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#goToOverride. I tried to integrate it as step one statically, see line 168 to 188, but the only paramter it accepts is "options.target.scale = 1500000;" (or any other number for scale). it doesn't accept neither center nor extent - it doesnot throw an error, it just doesnt do anything.
My aim is to combine my soon to be function starting at line 209 and the goToOverride-Option in a second step. For now, I'd be happy to just figure out, which variables I can pass to the goToOverride-Option. Could you help me with the latter?
minimal sample: https://codepen.io/nwp_nadja_bernhard/pen/ZERjWmw
search terms: Naturpark Gantrisch (or just: parc)
and a basic question to goToOverride: why do I need to set the scale at options.target.scale as in this example: https://community.esri.com/t5/arcgis-api-for-javascript-questions/detect-location-by-clicking-a-butt...>> solution at line 113. Why not use "target" instead of "options" as input, and change the parameters there (I tried it, didn't work): https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#GoToTarget2D
I'm using the search widget to search for parcel polygons. The search widget works great but I wanted it to zoom out slightly. I found the goToOverride function in the documentation but didn't see a good example of how to use it. Thanks to this post, I was able to get this working, see my example below. I was able to reference the selected graphic and expand its extent.
const searchWidget = new Search({
view: view,
popupEnabled: false,
//https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#goToOverride
goToOverride: function (view, options) {
//console.info(options);
options.target.target.geometry.extent.expand(2.0);
return view.goTo(options.target);
},
sources: [
{