HOW TO
You can have the Locate Address tool automatically zoom in to the first returned geocoded result by doing a few simple edits to your HTML Viewer's aimsGeocode.js file, as described below. The first result will always be the result with the highest score. This article also illustrates how to zoom in on the geocode result only if one result is returned.
Code:
if (GCpointCount==1) sendMapXML();
//if (GCpointCount==1) zoomToPoint(GCpointX[0], GCpointY[0], true, geocodeLabel);
Note:
This should take you to the bottom of the parseGeocodeResults function, which is responsible for parsing the ArcXML geocode response from the spatial server.
Code:
//if (GCpointCount==1) sendMapXML();
var gcptx = parseFloat(GCpointX[0]);
var gcpty = parseFloat(GCpointY[0]);
//if (GCpointCount==1) zoomToPoint(gcptx, gcpty, true, geocodeLabel);
zoomToPoint(gcptx, gcpty, true, geocodeLabel);
Note:
This will result in the map automatically zooming to the first geocode result returned. The zoomToPoint function is already set up to do this.
Code:
if (GCpointCount==1) zoomToPoint(gcptx, gcpty, true, geocodeLabel);
Code:
zoomToPoint(gcptx, gcpty, true, geocodeLabel);
Note:
Two forward slashes (//) are the comment characters in Java Script.
Article ID:000003000
Get help from ArcGIS experts
Download the Esri Support App