| Package | com.esri.aws.services |
| Interface | public interface IPlaceFinder |
See also
| Method | Defined by | ||
|---|---|---|---|
|
findPlace(placeName:String, placeFinderOptions:PlaceFinderOptions, responder:IResponder):void
Returns the lat,lon coordinates and descriptions of all places that meet a given search criteria.
| IPlaceFinder | ||
| findPlace | () | method |
public function findPlace(placeName:String, placeFinderOptions:PlaceFinderOptions, responder:IResponder):voidReturns the lat,lon coordinates and descriptions of all places that meet a given search criteria. The result of the responder will be of type GeocodeInfo.
ParametersplaceName:String — the placeName to search on.
|
|
placeFinderOptions:PlaceFinderOptions — search options
|
|
responder:IResponder — the responder to call on result/fault
|
See also
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:awx="http://www.arcwebservices.com/2007/awx"
pageTitle="Basic PlaceFinder Report"
implements="mx.rpc.IResponder"
creationComplete="onComplete()"
>
<mx:Script>
<![CDATA[
import com.esri.aws.osgi.framework.ServiceTracker;
import com.esri.aws.services.GeocodeCandidate;
import com.esri.aws.services.GeocodeInfo;
import com.esri.aws.services.IPlaceFinder;
import com.esri.aws.services.PlaceFinderOptions;
import com.esri.aws.osgi.framework.IServiceReference;
import flash.utils.getQualifiedClassName;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.IResponder;
[Bindable]
private var candidates:ArrayCollection;
private var placeTracker:ServiceTracker;
private function onComplete():void
{
placeTracker = new ServiceTracker(Framework.getInstance().systemContext, getQualifiedClassName(IPlaceFinder));
placeTracker.open();
}
private function doSearch():void
{
var placeService:IPlaceFinder = placeTracker.getService() as IPlaceFinder;
if(placeService)
{
//build some simple options
var pfOptions:PlaceFinderOptions = new PlaceFinderOptions();
pfOptions.dataSource = "auto"; // ArcWeb:ESRI.Gazetteer.World
//call the PlaceFinder service using 'this' as the responder.
placeService.findPlace(locationText.text,pfOptions,this);
m_info.htmlText = "Sending request ...";
}
}
public function result(data:Object):void
{
var m_geocodeInfo:GeocodeInfo = GeocodeInfo(data);
m_info.htmlText = "<i>Showing " + m_geocodeInfo.candidates.length ;
m_info.htmlText += " of " + m_geocodeInfo.totalCount + ".</i><br/>";
candidates = new ArrayCollection(m_geocodeInfo.candidates);
if (candidates.length > 0 )
{
for(var i:int=0; i< candidates.length; i++)
{
var gc:GeocodeCandidate = candidates[i];
m_info.htmlText += "<b>" + gc.desc1 + "</b> at <b>"
+ gc.latLon.y + "," + gc.latLon.x + "</b> [" + gc.type + "]<br>";
}
}
else
{
m_info.htmlText += "<b>No matches.";
}
}
public function fault(info:Object):void
{
Alert.show(info.toString());
}
]]>
</mx:Script>
<awx:Framework id="m_framework" apiKey="[MY-API-KEY]" >
<awx:PlaceFinderActivator/>
</awx:Framework>
<mx:Panel paddingTop="5" paddingLeft="5" paddingBottom="5" paddingRight="5"
width="100%"
title="Place Finder Search" layout="horizontal">
<mx:TextInput width="95%" id="locationText" text="Paradise" enter="doSearch()"/>
<mx:Button label="Find Place" click="doSearch()" id="m_button" />
</mx:Panel>
<mx:Text id="m_info" fontSize="14" top="80"/>
</mx:Application>