Select to view content in your preferred language

Writing more than just an address field from a Locator in Flex

2183
1
12-17-2012 05:24 AM
KarlBarker-Ottley
Emerging Contributor
Hi,

I have a locator service which has access to a variety of fields and would like to write one of these fields into a tooltip that appears if the address is successfully located. The field is called ???Street_ID???. I am trying to adapt the example script found in the ESRI Flex Samples site - below is an extract of the mxml; if someone could highlight what I need to include to get this field to write, It would be appreciated:

<fx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.layers.GraphicsLayer;
import com.esri.ags.tasks.supportClasses.AddressCandidate;
import com.esri.ags.tasks.supportClasses.AddressToLocationsParameters;

import mx.controls.Alert;
import mx.rpc.AsyncResponder;

private function doFind():void
{
var parameters:AddressToLocationsParameters = new AddressToLocationsParameters();

parameters.address = { SingleLine: onelineaddress.text };

parameters.outFields = ["Loc_name"];

locator.addressToLocations(parameters, new AsyncResponder(onResult, onFault));
function onResult(candidates:Array, token:Object = null):void
{
if (candidates.length > 0)
{
var addressCandidate:AddressCandidate = candidates[0];
var myGraphic:Graphic = new Graphic();

myGraphic.geometry = addressCandidate.location;
myGraphic.symbol = mySymbol;
myGraphic.toolTip = addressCandidate.address.toString();
myGraphic.id = "graphic";
myGraphicsLayer.add(myGraphic);

myMap.centerAt(myGraphic.geometry as MapPoint);
if (addressCandidate.attributes.Loc_name.search("RoofTop") > 0)
{
myMap.scale = 9027.977411;
}
myInfo.htmlText = "<b>Found:</b><br/>" + addressCandidate.address.toString();
}
else
{
myInfo.htmlText = "<b><font color='#FF0000'>No Location Found</b></font>";

Alert.show("Sorry, couldn't find a location for this address"
+ "\nAddress: " + onelineaddress.text);
};
}

function onFault(info:Object, token:Object = null):void
{
myInfo.htmlText = "<b>Failure</b>" + info.toString();
Alert.show("Failure: \n" + info.toString());
}
}

private function clearMap():void
{
myGraphicsLayer.clear();
Alert.show("Points cleared");
}
]]>
</fx:Script>

Thanks,
Karl
Tags (2)
0 Kudos
1 Reply
KarlBarker-Ottley
Emerging Contributor
I was wondering if anyone has had any further thoughts on this issue?
Thanks,
Karl
0 Kudos