Hello,I have an Array of address objects and am currently looping through each array element and calling locateTask.addressToLocations() for each.It works, but it's ugly, lots of moving around and scaling occuring for each address as it's located.I was wondering what the proper way to do this is please and how to set map scale to have all markers in view.The scaling is done as if for one marker:private function mapAddressResult(candidates:Array,token:Object=null):void
{
if(candidates.length > 0)
{
var addressCandidate:AddressCandidate=candidates[0];
var mapGraphic:Graphic=new Graphic();
mapGraphic.geometry=addressCandidate.location;
mapGraphic.symbol=selectedSymbol;
mapGraphic.toolTip=addressCandidate.address.toString();
mapGraphic.id="graphic";
graphicsLayer.add(mapGraphic);
map.centerAt(addressCandidate.location);
// Zoom to an appropriate level
// Note: your tile levels and LOC_NAME might differ...
if (addressCandidate.attributes.Loc_name.search("RoofTop") > 0)
{
map.scale=10000;
}
else if (addressCandidate.attributes.Loc_name.search("Address")>0)
{
map.scale=10000;
}
else if (addressCandidate.attributes.Loc_name.search("Street")>0)
{
map.scale=15000;
}
else if (addressCandidate.attributes.Loc_name.search("Zipcode")>0)
{
map.scale=40000;
}
else if (addressCandidate.attributes.Loc_name.search("City")>0)
{
map.scale=150000;
}
else
{
map.scale=500000;
}
}
}
That method is called for each of the addresses, hence the re-centering and re-scaling each time one is located.How do I do this properly please?Thank you.