AnsweredAssumed Answered

Locator not solving in right order

Question asked by thewabbit on Jul 8, 2015
Latest reply on Jul 9, 2015 by rscheitlin

Hey there

I've a list of addresses that I want to solve, ive tried two things:

  1. using locator.addressToLocations - I iterate through the list of addresses. This will solve the results, but sometimes they will not be in the same order as they were in the list - this is an issue.
  2. using locator.addressessToLocations - this will simply not solve. I can't even get it to work in the REST end point.

 

I'd like to try to fix the issues with my first attempt as i also need to do some other things during the iteration. Below is my code:

 

    
for (i in depotLocs) {
        
console.log(i)
        
var locator = new esri.tasks.Locator(this.config.geoCoder);
        
console.log("A")
        
locator.outSpatialReference = sRef;
        
console.log("B")
        
var optionsFrom = {
            
address: { "SingleLine": depotLocs[i] },
            
outFields: ["Loc_name"]
        
};
      
 
        
locator.addressToLocations(optionsFrom,function(candidate){
            
var r = candidate;
            
facilitiesGraphicsLayer.add(new Graphic(new Point(r[0].location.x,r[0].location.y,sRef)));
            
depotGraphic.push(new Graphic(new Point(r[0].location.x,r[0].location.y,sRef)));
            
console.log(i)
            
console.log(r[0].location.x)
            
console.log(r[0].location.y)
            
}); 


 

Does anyone have a possible solution to it being solved out of order? it is a bit of pain as it doesn't consistently happen.

 

Cheers

 

Hamish

Outcomes