I would like to set the geocoder to zoom to 1:1200. I think I would change the expand.0.0625 for the Point geometry but I am not sure.
if (feature) { var resultGeometry = feature.geometry; if (resultGeometry.type === 'point') { anchorPoint = resultGeometry; zoomExtent = this.map.extent.centerAt(anchorPoint).expand(0.0625); } else if (resultGeometry.type === 'polyline') { anchorPoint = resultGeometry.getPoint(0, 0); zoomExtent = resultGeometry.getExtent().expand(1.1); } else if (resultGeometry.type === 'polygon') { anchorPoint = resultGeometry.getCentroid(); zoomExtent = resultGeometry.getExtent().expand(1.1); } else if (resultGeometry.type === 'mulitpoint') { anchorPoint = resultGeometry.getPoint(0); zoomExtent = resultGeometry.getExtent().expand(1.1); } else { anchorPoint = resultGeometry; zoomExtent = this.map.extent; }
Solved! Go to Solution.
Hi Robert,
I created a geocoder service using a polygon feature, the search widget result zoom really close on the map. I tried to find the location as pointed above but can't seem to find the code to change the zoom scale extent setting.
Ha Thach,
This thread has t do with WAB 1.1. The search widget does not have a show results function (as it is all handled by the JS API internally).
Thanks Robert. Will there be some functions like this available on the next release of WAB 1.3?
Not that I am aware of. It would involve an JS API change.
Is it zooming in closer than the full extent of the polygon (i.e., can't see the entirety of the polygon you search for)? If so, you can calculate the polygon extents and configure that in the locator, before publishing the geocode service.
Yes, this is what I wanted to do. I tried your approach by creating a new field "zoomExtent" and calculate using the shape area field. I didn't get it to work. Am I doing something wrong? This is what I get....
Here is how I setup for my system locator....
If using a Geocode service, the zoom extents can be configured in the locator before publishing to a service. For a polygon feature, to set the zoom extent as the outer boundary (to show the entire polygons), try the following:
Once you publish the locator as a Geocode service and source the service in your web app geocode/search widget, the result is zoomed to these defined extents.
Does this get at what you need?
Thanks Andrews, it works on my end. I'm really appreciated for all your help.