Select to view content in your preferred language

Geocoding with local geocoder: map does not zoom to results

3455
3
Jump to solution
03-07-2013 09:36 AM
ErikEndrulat
Regular Contributor
I???m attempting to reconfigure a geocoding application based on the Javascript API sample here:
http://help.arcgis.com/en/webapi/javascript/arcgis/jstutorials/#tutorial_geocoder

The only changes that I've made to the original code are 1) referencing my own webmap, and 2) reference a local geocoder service. The application can be viewed here:
https://dl.dropbox.com/u/1208356/geocode_coastalBoundary_v3.html

The application works as expected except instead of zooming to the location searched for or selected from the dropdown list,  it places the point and recenters the map (extent stays the same). I need to determine how to zoom to the results returned by my own geocoding service.

The code doesn't have any functions that explicitly take the geometry from the geocoding results and reset the map extent based on these, so i'm assuming this is something built into the geocoding digit.  I explored the JSON returned from Esri's geocoding service and compared it to what was returned from my own ArcGIS Server, and see there are many differences in the elements returned (e.g., own instance of ArcGIS Server returns 'location' containing x/y coordinates; whereas Esri's geocoding service includes the x/y coordinates in the 'geometry', and also returns the extent (strange, for a point feature..)


JSON from ArcGIS Server:  spatialReference wkid : 102100 [number] candidates 0 address : 97301 [string] location x : -13692817.9706 [number] y : 5613666.2399 [number] score : 100 [number] attributes   JSON from Esri's Geocode service:  spatialReference wkid : 102100 [number] latestWkid : 3857 [number] locations 0 name : 97330, Corvallis, OR [string] extent xmin : -13728247.885804845 [number] ymin : 5549357.770796694 [number] xmax : -13717115.936725518 [number] ymax : 5564989.215078552 [number] feature geometry x : -13722681.804322762 [number] y : 5557170.2004600745 [number] attributes Score : 100 [number] Addr_Type : Postal [string] 1


Does anyone have any thoughts on how to best make this work, i.e., enable zoom-to-address using on-premise ArcGIS Server Geocoding service?

Thank you,
Erik Endrulat
0 Kudos
1 Solution

Accepted Solutions
JohnGravois
Deactivated User
our own geocoding service uses a "find" operation which returns both the geometry of each candidate and an individual extent which i assume is what the geocoder widget uses to determine how far to zoom in.

example from geocode.arcgis.com:
{     "name" : "1233 SE Main St, Portland, OR, 97214",         "extent" : {   "xmin" : -13653815.11016134,   "ymin" : 5702594.5923811821,   "xmax" : -13653592.471179754,   "ymax" : 5702912.3125919709  },  "feature" : {   "geometry" : {           "x" : -13653703.684547694,           "y" : 5702753.3918946823           },           "attributes" : {    "Score" : 100,    "Addr_Type" : "StreetAddress"   }  } }


i found that a call to a custom locator leverages the 'findAddressCandidates' operation, which usually only returns geometry:
{  "address" : "1233 SE MAIN ST, Portland, 97214",  "location" : {   "x" : -13653654.8506,   "y" : 5702774.4558999985  },  "score" : 100,  "attributes" : {}  }


you could figure out how to get your own geocoding service to return extents, but it would probably be a lot easier to set the zoom level to something static (and appropriate) when a geocoder event like 'onSelect' is triggered.

dojo.connect(Geocoder, 'onSelect', function(results){  map.setLevel(12);  });

View solution in original post

3 Replies
BillHoney
Occasional Contributor
Erik,
did you get anywhere with this ? I have exactly the same problem

Regards, Bill
0 Kudos
JohnGravois
Deactivated User
our own geocoding service uses a "find" operation which returns both the geometry of each candidate and an individual extent which i assume is what the geocoder widget uses to determine how far to zoom in.

example from geocode.arcgis.com:
{     "name" : "1233 SE Main St, Portland, OR, 97214",         "extent" : {   "xmin" : -13653815.11016134,   "ymin" : 5702594.5923811821,   "xmax" : -13653592.471179754,   "ymax" : 5702912.3125919709  },  "feature" : {   "geometry" : {           "x" : -13653703.684547694,           "y" : 5702753.3918946823           },           "attributes" : {    "Score" : 100,    "Addr_Type" : "StreetAddress"   }  } }


i found that a call to a custom locator leverages the 'findAddressCandidates' operation, which usually only returns geometry:
{  "address" : "1233 SE MAIN ST, Portland, 97214",  "location" : {   "x" : -13653654.8506,   "y" : 5702774.4558999985  },  "score" : 100,  "attributes" : {}  }


you could figure out how to get your own geocoding service to return extents, but it would probably be a lot easier to set the zoom level to something static (and appropriate) when a geocoder event like 'onSelect' is triggered.

dojo.connect(Geocoder, 'onSelect', function(results){  map.setLevel(12);  });
ErikEndrulat
Regular Contributor
Thanks, John - That's exactly what I ended up doing.

I was hoping that when we migrated to 10.1 there was an option for the geocoding services to return an extent, but it appears that's not the case.

Best,
Erik
0 Kudos