AnsweredAssumed Answered

Using Locator in 4.5 api for geocoding

Question asked by gilbertgis on Nov 8, 2017
Latest reply on Nov 13, 2017 by gilbertgis

I am trying without much success to geocode an address in my javascript application using the Locator.  I set up a geocode service, and tested that service successfully, but calling it from javascript returns nothing.  There really isn't much as far as samples for this Locator object (esri/tasks/Locator), so I'm hoping maybe someone has done this successfully and could share this info.

 

This is the function (with the address passed into val), as far as I can tell the parameters are passed in as an object, and the promise returns the value returned by the geocode service.  I just get a 0 length array when I do this.  (The city, "GILB", is an abbreviated city code that we use in our streets layer.  This works when querying the geocode service itself).

 

 

  var addr={
    "Street": val,
    "City": "GILB"
  }
  addLoc.outSpatialReference=view.spatialReference;
  addLoc.addressToLocations(addr).then(function(response) {
    console.log(response);
  })
  .otherwise(function(err) {
    window.alert(val + " Not Found (geo)");
  });

 

The response I get is the 0 length array, and not the "Not Found" dialog, so I think this is not creating an error, just not getting the value from the geocode service.

 

If anyone has had success with this, and would be willing to point me in the right direction, I would be grateful.

 

Thank you in advance for your assistance.

 

Jeff

Outcomes