Select to view content in your preferred language

Reverse Geocode by latitude and longitude

3122
1
09-20-2012 07:36 AM
MIkeColonna
New Contributor
Hello all,

I'm a newbie to ArcGIS

I been searching around the forum and got most of my questions answer without having to post one of my own until now.

I have the  latitude and longitude  and I need Reverse Geocode to find the state.

I don't need the MAP so I'm not sure if there is way to pass a function the latitude and longitude and get the candidate.address object?


any help would be great thanks.
Tags (2)
0 Kudos
1 Reply
MIkeColonna
New Contributor
Found the answer:  had the  lat-lon Reverse and the wrong SpatialReference below is the simple app if anyone else new runs into this problem...


<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:mx="library://ns.adobe.com/flex/mx"
        xmlns:esri="http://www.esri.com/2008/ags">
 
 
 
 
 <fx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.SpatialReference;
   import com.esri.ags.events.GraphicEvent;
   import com.esri.ags.events.LocatorEvent;
   import com.esri.ags.events.MapMouseEvent;
   import com.esri.ags.geometry.Extent;
   import com.esri.ags.geometry.MapPoint;
   import com.esri.ags.tasks.Locator;
   import com.esri.ags.tasks.supportClasses.AddressCandidate;
   import com.esri.ags.utils.WebMercatorUtil;
   import com.esri.ags.tasks.supportClasses.AddressCandidate;
   import mx.rpc.events.FaultEvent;
  
   
   
   
   private function onLocationToAddressComplete(event:LocatorEvent):void
   {
    var candidate:AddressCandidate = event.addressCandidate;
    state.text=candidate.address.State;
   }
   
   
   protected function button1_clickHandler(event:MouseEvent):void
   {
    
    locateTask.locationToAddress(myPoint,100);
    
   }
   
   private function onFault(event:FaultEvent):void
   {
   
    trace(event.fault.faultString);
    
    state.text= " error:" + event.fault.faultDetail;
    //url="http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_NA/GeocodeServer" 
   }
   
  ]]>
 </fx:Script>

 <fx:Declarations>
  <esri:Graphic>
   <esri:MapPoint id="myPoint" x="-121.645"  y="46.339" spatialReference="{new SpatialReference(4152)}"/>
  </esri:Graphic>
  
  <esri:Locator id="locateTask" 
       url="http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_NA_10/GeocodeServer" 
       concurrency="last"
       locationToAddressComplete="onLocationToAddressComplete(event)" 
       fault="onFault(event)"/>

 </fx:Declarations>
 
 
 <s:Button x="10" y="10" label="Button" click="button1_clickHandler(event)"/>
 <s:Label id="state" x="92" y="10" width="567" height="589" text="Label"/>
 
</s:WindowedApplication>
0 Kudos