I am new to ArcGIS API for Flex and want to use the address locator in a map using locally projected data layers. Everything is local and rscheitlin posts for this very issue in the Flex Viewer http://forums.arcgis.com/threads/2666-Locator-in-sample-working-but-still-using-wrong-coordinate-sys... were very useful, but i can't seem to translate it over to the API. I apologize for the layout of the code below, it is scattered in several places throughout the mxml.
Here is what we have so far:
// Look up for Address private function doFind():void { var myAddress:Object = { Address: address.text, City: city.text, State: state.text, Zip: zip.text, /* Country: country.selectedItem */ Country: "USA" }; // Use outFields to get back extra information // The exact fields available depends on the specific Locator used. var myOutFields:Array = [ "Loc_name" ]; locateTask.addressToLocations(myAddress, myOutFields, 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(); //trace(addressCandidate.location); myGraphic.geometry = WebMercatorUtil.geographicToWebMercator(addressCandidate.location); //trace(myGraphic.geometry); myGraphic.symbol = mySymbol; myGraphic.toolTip = addressCandidate.address.toString(); myGraphic.id = "graphic"; geocodeLayer.add(myGraphic); mainMap.centerAt(myGraphic.geometry as MapPoint); // Zoom to an appropriate level // Note: your tile levels and LOC_NAME might differ... if (addressCandidate.attributes.Loc_name.search("RoofTop") > 0) { mainMap.scale = 10000; } else if (addressCandidate.attributes.Loc_name.search("Address") > 0) { mainMap.scale = 10000; } else if (addressCandidate.attributes.Loc_name.search("Street") > 0) { mainMap.scale = 15000; } else if (addressCandidate.attributes.Loc_name.search("Zipcode") > 0) { mainMap.scale = 40000; } else if (addressCandidate.attributes.Loc_name.search("City") > 0) { mainMap.scale = 150000; } else { mainMap.scale = 500000; } //myInfo.htmlText = "<b>Found:</b><br/>" + addressCandidate.address.toString(); // formated address } else { //myInfo.htmlText = "<b><font color='#FF0000'>Found nothing :(</b></font>"; Alert.show("Sorry, couldn't find a location for this address" + "\nAddress: " + address.text + "\nCity: " + city.text + "\nZIP Code: " + zip.text + "\nState: " + state.text /* + "\nCountry: " + country.selectedItem) */ + "\nCountry: USA"); } } <fx: Declarations> <esri:Locator id="locateTask" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Locators/ESRI_Geocode_USA/GeocodeServer"/> <esri:SimpleMarkerSymbol id="mySymbol" alpha="0.5" color="0xFF0000" size="19" style="circle"> <esri:SimpleLineSymbol width="2"/> </esri:SimpleMarkerSymbol>