Select to view content in your preferred language

Can you copy text input from one Geocoder text to another one?

886
3
Jump to solution
03-13-2014 08:02 AM
MayJeff
Deactivated User
I create two Geocoder compenent. One use my own geocode locator service and another one use ESRI.  See my attachment file.  I want to use a text I type in header controller widget and show it on search widget so won't need to retype it. Just like copy and paste it manually.  Is there possible?  
Hope someone can help.
Thanks.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
May Jeff,

   In the HeaderControllerWidget.mxml make these changes:

            protected function singleLineSearch_keyUpHandler(event:KeyboardEvent):void             {                 addSharedData("esriGeocoderText", new ArrayCollection([singleLineSearch.geocoder.text]));             }                 <components:GeocoderComponent id="singleLineSearch"                                               width="230" height="28"                                               includeInLayout="false"                                               visible="false"                                               keyUp="singleLineSearch_keyUpHandler(event)"/>


and here is an example widget that listens for that data and adds the text you type in the main geocoder to a new geocoder:

<viewer:BaseWidget 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"                    xmlns:viewer="com.esri.viewer.*"                    xmlns:components="com.esri.viewer.components.*"                    widgetConfigLoaded="init()">     <fx:Script>         <![CDATA[             import mx.collections.ArrayCollection;             import com.esri.viewer.utils.Hashtable;             import com.esri.viewer.AppEvent;                          private function sharedDataUpdated(event:AppEvent):void             {                 if (event.data.key == "esriGeocoderText")                 {                     if (event.data.collection[0]){                         singleLineSearch.geocoder.text = event.data.collection[0];                     }                 }             }                          private function sharedDataUpdated2(event:AppEvent):void             {                 var dataTable:Hashtable = event.data as Hashtable;                 if (dataTable.containsKey("esriGeocoderText"))                 {                     var recAC:ArrayCollection = dataTable.find("esriGeocoderText") as ArrayCollection;                     for (var i:Number = 0; i < recAC.length; i++)                     {                         singleLineSearch.geocoder.text = recAC;                     }                     dataTable.remove("esriGeocoderText");                 }else if(dataTable.containsKey("Deactivate_DrawTool")){                     setMapAction(null, null, null, null);                 }             }                          private function init():void             {                 if (configXML){                     var geocoderXML:XML = configXML.geocoder[0] || configXML.search[0];                                          const shouldEnableGeocoder:Boolean = geocoderXML && (geocoderXML.@visible[0] != "false");                     if (shouldEnableGeocoder)                     {                         singleLineSearch.hostBaseWidget = this;                         singleLineSearch.includeInLayout = true;                         singleLineSearch.visible = true;                     }                 }                 AppEvent.addListener(AppEvent.DATA_PUBLISH, sharedDataUpdated);                 AppEvent.addListener(AppEvent.DATA_SENT, sharedDataUpdated2);                 fetchSharedData();             }                      ]]>     </fx:Script>          <viewer:WidgetTemplate id="wTemplate"                            width="275" height="120">         <components:GeocoderComponent id="singleLineSearch"                                        width="230" height="28"                                       includeInLayout="false"                                       visible="false"/>     </viewer:WidgetTemplate> </viewer:BaseWidget>

View solution in original post

0 Kudos
3 Replies
MayJeff
Deactivated User
How about use my own geocode locator serviceto search first, if no result match your textinput then use ESRI geocorder to search?
I try to modify geocoder component to perform this function.  Hope someone got some ideas?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
May Jeff,

   In the HeaderControllerWidget.mxml make these changes:

            protected function singleLineSearch_keyUpHandler(event:KeyboardEvent):void             {                 addSharedData("esriGeocoderText", new ArrayCollection([singleLineSearch.geocoder.text]));             }                 <components:GeocoderComponent id="singleLineSearch"                                               width="230" height="28"                                               includeInLayout="false"                                               visible="false"                                               keyUp="singleLineSearch_keyUpHandler(event)"/>


and here is an example widget that listens for that data and adds the text you type in the main geocoder to a new geocoder:

<viewer:BaseWidget 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"                    xmlns:viewer="com.esri.viewer.*"                    xmlns:components="com.esri.viewer.components.*"                    widgetConfigLoaded="init()">     <fx:Script>         <![CDATA[             import mx.collections.ArrayCollection;             import com.esri.viewer.utils.Hashtable;             import com.esri.viewer.AppEvent;                          private function sharedDataUpdated(event:AppEvent):void             {                 if (event.data.key == "esriGeocoderText")                 {                     if (event.data.collection[0]){                         singleLineSearch.geocoder.text = event.data.collection[0];                     }                 }             }                          private function sharedDataUpdated2(event:AppEvent):void             {                 var dataTable:Hashtable = event.data as Hashtable;                 if (dataTable.containsKey("esriGeocoderText"))                 {                     var recAC:ArrayCollection = dataTable.find("esriGeocoderText") as ArrayCollection;                     for (var i:Number = 0; i < recAC.length; i++)                     {                         singleLineSearch.geocoder.text = recAC;                     }                     dataTable.remove("esriGeocoderText");                 }else if(dataTable.containsKey("Deactivate_DrawTool")){                     setMapAction(null, null, null, null);                 }             }                          private function init():void             {                 if (configXML){                     var geocoderXML:XML = configXML.geocoder[0] || configXML.search[0];                                          const shouldEnableGeocoder:Boolean = geocoderXML && (geocoderXML.@visible[0] != "false");                     if (shouldEnableGeocoder)                     {                         singleLineSearch.hostBaseWidget = this;                         singleLineSearch.includeInLayout = true;                         singleLineSearch.visible = true;                     }                 }                 AppEvent.addListener(AppEvent.DATA_PUBLISH, sharedDataUpdated);                 AppEvent.addListener(AppEvent.DATA_SENT, sharedDataUpdated2);                 fetchSharedData();             }                      ]]>     </fx:Script>          <viewer:WidgetTemplate id="wTemplate"                            width="275" height="120">         <components:GeocoderComponent id="singleLineSearch"                                        width="230" height="28"                                       includeInLayout="false"                                       visible="false"/>     </viewer:WidgetTemplate> </viewer:BaseWidget>
0 Kudos
MayJeff
Deactivated User
Thank you very much Robert.  You're so awesome:)
0 Kudos