Hello, I am using 'Geode an address' sample from resources website with my own geocode server services for a test but I got some ActionScript error messages after click on"Find Adress" button. On my own services, I only have 'Street' for address Fields. Can someone let me know why I got these messages? ********************* Here are ActionScript error: ********************* TypeError: Error #1010: A term is undefined and has no properties. at testing/private:doFind/onResult() at mx.rpc::AsyncResponder/result() at com.esri.ags.tasks::Locator/handleAddressCandidates() at Function/http://adobe.com/AS3/2006/builtin::call() at com.esri.ags.tasks::BaseTask/handleResult() at <anonymous>() at mx.rpc::Responder/result() at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult() at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders() at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent() at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler() at mx.rpc::Responder/result() at mx.rpc::AsyncRequest/acknowledge() at DirectHTTPMessageResponder/completeHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete()
********************* Here is the testing.mxml file ********************* <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="Locator task" layout="absolute"> <!-- Problem: How to find the address (aka geocoding) for a certain address?
Solution: Use the addressToLocations() method on the Locator.
This sample takes a user-provided address and sends it to the server for geocoding. When the response comes back, the OnResult() function creates a graphic for the result and then sets the scale appropriately based on if the match was a "street", "city" etc match. --> <mx:Script> <![CDATA[ import com.esri.ags.Graphic; import com.esri.ags.tasks.AddressCandidate; import mx.controls.Alert; import mx.rpc.AsyncResponder;
private function doFind():void { var myAddress:Object = { Street: address.text }; // 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(); myGraphic.geometry = addressCandidate.location; myGraphic.symbol = mySymbol; myGraphic.toolTip = addressCandidate.address.toString(); myGraphic.id = "graphic"; myGraphicsLayer.add(myGraphic); myMap.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) { myMap.scale = 10000; } else if (addressCandidate.attributes.Loc_name.search("Address") > 0) { myMap.scale = 10000; } else if (addressCandidate.attributes.Loc_name.search("Street") > 0) { myMap.scale = 15000; } else if (addressCandidate.attributes.Loc_name.search("Zipcode") > 0) { myMap.scale = 40000; } else if (addressCandidate.attributes.Loc_name.search("City") > 0) { myMap.scale = 150000; } else { myMap.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); } } function onFault(info:Object, token:Object = null):void { myInfo.htmlText = "<b>Failure</b>" + info.toString(); Alert.show("Failure: \n" + info.toString()); } } ]]> </mx:Script> <esri:Locator id="locateTask" url="http://gis:8399/arcgis/rest/services/test/strLineAddrLoc/GeocodeServer"/> <esri:SimpleMarkerSymbol id="mySymbol" size="19" style="circle" color="0xFF0000" alpha="0.5"> <esri:SimpleLineSymbol width="2"/> </esri:SimpleMarkerSymbol> <!-- End Declarations -->