Select to view content in your preferred language

how to change the zoom scale for the geocoder?

5097
17
Jump to solution
06-09-2015 07:23 AM
Pulaski_AreaGIS
New Contributor

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;
          }
0 Kudos
17 Replies
haThach
New Contributor III

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.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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).

0 Kudos
haThach
New Contributor III

Thanks Robert. Will there be some functions like this available on the next release of  WAB 1.3?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Not that I am aware of. It would involve an JS API change.

0 Kudos
ColeAndrews
Occasional Contributor III

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.

0 Kudos
haThach
New Contributor III

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....

systemExtent.png

Here is how I setup for my system locator....

systemLocator.png

0 Kudos
ColeAndrews
Occasional Contributor III

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:

  • In ArcMap, run "Add Geometry Attributes" tool. Input the polygon file and select EXTENT. Run.
  • The ymin, ymax, xmin,xmax values are added for each feature.

         

  • Configure the locator display extents to use the calculated extent fields. Create locator.
  • When you're done creating the locator, right click>>properties and make sure the output display extents is set to "yes"

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?

0 Kudos
haThach
New Contributor III

Thanks Andrews, it works on my end. I'm really appreciated for all your help.