Problem on using own locator service for geocoder

2515
7
Jump to solution
06-17-2013 08:29 AM
MayJeff
Occasional Contributor
Did anyone use thier own locator service for geocoder? I try to modify the sample here :http://forums.arcgis.com/threads/82293-Geocoder-render-a-point-on-the-map-once-result-is-selected?hi... and add my own locator service but it didn't display auto-complete results and won't zoom to the location either. 

Here is my code:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:esri="http://www.esri.com/2008/ags"
      pageTitle="Geocoder Component Sample">
<fx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.events.GeocoderEvent;
   import com.esri.ags.geometry.Geometry;
   import com.esri.ags.symbols.SimpleFillSymbol;
   import com.esri.ags.symbols.SimpleMarkerSymbol;
   import com.esri.ags.symbols.Symbol;
  
   import mx.controls.Alert;
   import mx.rpc.events.FaultEvent;
  
   protected function onGeocoderResultSelected(event:GeocoderEvent):void
   {
    var symbol:Symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 24, 0xFF0000);
    var gr:Graphic = new Graphic(event.result.geometry, symbol);
    gr.toolTip = event.result.label + "\n(" + event.result.sourceName + ")";
    gLayer.clear();
    gLayer.add(gr);
   }
  
   protected function onGeocoderFault(event:FaultEvent):void
   {
    Alert.show(event.message.toString(), "Geocoder fault");
   }
  
   protected function onGeocoderSearchComplete(event:GeocoderEvent):void
   {
    // do something
   }
  
  ]]>
</fx:Script>

<esri:Map id="map">
  <esri:ArcGISDynamicMapServiceLayer url="http://{url}/ArcGIS/rest/services/test/Internet/MapServer"/>
  <esri:GraphicsLayer id="gLayer" />
</esri:Map>

<esri:Geocoder width="300" height="30" url="http://{url}/ArcGIS/rest/services/test/addrPoint/GeocodeServer" autoComplete="true" proxyURL="http://{url}/proxy/proxy.ashx"
       top="20" minCharacters="3"
       horizontalCenter="0"
       map="{map}"
       resultSelected="onGeocoderResultSelected(event)"
       fault="onGeocoderFault(event)"
       searchComplete="onGeocoderSearchComplete(event)" />
</s:Application>

Thank you.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
BjornSvensson
Esri Regular Contributor
...my own locator service but it didn't display auto-complete results and won't zoom to the location either. 

To enable autoComplete, you need to turn on the autoComplete property.
http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/components/Geocoder.html#autoComple...

The zoom to location only works if the geocode service returns something similar to an extent that can be used for the zoom. For example, the esri-provided locator returns Xmin, Xmax, Ymin, Ymax fields in geographics coordinates that the geocoder can then use to zoom with.

View solution in original post

0 Kudos
7 Replies
BjornSvensson
Esri Regular Contributor
...my own locator service but it didn't display auto-complete results and won't zoom to the location either. 

To enable autoComplete, you need to turn on the autoComplete property.
http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/components/Geocoder.html#autoComple...

The zoom to location only works if the geocode service returns something similar to an extent that can be used for the zoom. For example, the esri-provided locator returns Xmin, Xmax, Ymin, Ymax fields in geographics coordinates that the geocoder can then use to zoom with.
0 Kudos
MayJeff
Occasional Contributor
I added esri:Extent to it still not doing anything.  The search box just not show up any results and not able to zoom.  I wonder esri:Geocoder didn't recognize my url at all.  If I didn't define any url on esri:Geocoder then it works perfectly but if define own url then it won't works.  Pretty interesting.
0 Kudos
BjornSvensson
Esri Regular Contributor
esri:extent doesn't have anything to do with this.  It's the locator that needs to have those fields.

Are you using the Geocoder to search a locator service or a map service?

Is your geocode service publicly available?  If not, probably best to work with Esri Support to work through your specific issue.
0 Kudos
MayJeff
Occasional Contributor
I use Geocoder to search a locator service and my geocode service is not public.  Sounds like not easy to run a test.  I can work on Header Controller widget for ArcGIS Viewer for Flex using my own url. It returns all the results.
Thank you for replying my thread.
0 Kudos
LloydHeberlie
Occasional Contributor
To enable autoComplete, you need to turn on the autoComplete property.
http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/components/Geocoder.html#autoComple...

The zoom to location only works if the geocode service returns something similar to an extent that can be used for the zoom. For example, the esri-provided locator returns Xmin, Xmax, Ymin, Ymax fields in geographics coordinates that the geocoder can then use to zoom with.


Whenever you create your locator and pick an address style, the underlying data needs to support the Locator Style you choose.  When you populate the "Field Map" between the locator style and the fields in the data source, you need to have data for "Min X value for extent, Max X value for extent, Min Y value for extent, and Max Y value for extent".  Then you can choose to have the outputs of the locator properties to include the "Return display extent output fields".  If your data source does not contain this reference data, you would need to collect or create that data.  Also, commerical datasets for purchase similar to Streetmap Premium for ArcGIS contain this detailed level of data.
See the "Return display extent out fields" in the ArcGIS help.

Hope this helps clarify your issue.
0 Kudos
LloydHeberlie
Occasional Contributor
Whenever you create your locator and pick an address style, the underlying data needs to support the Locator Style you choose.  When you populate the "Field Map" between the locator style and the fields in the data source, you need to have data for "Min X value for extent, Max X value for extent, Min Y value for extent, and Max Y value for extent".  Then you can choose to have the outputs of the locator properties to include the "Return display extent output fields".  If your data source does not contain this reference data, you would need to collect or create that data.  Also, commerical datasets for purchase similar to Streetmap Premium for ArcGIS contain this detailed level of data.
See the "Return display extent out fields" in the ArcGIS help.

Hope this helps clarify your issue.
0 Kudos
MayJeff
Occasional Contributor
Easy way just use the GeocoderComponent on flex viewer and works!  Thanks.
0 Kudos