<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Activating the mapClick function through a component. in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165402#M3864</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Rene,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I understand using the event listener for the map click, but how do I call the mapClickHandler function (the identify function) in the Main.mxml from the event listener in the buttons.mxml?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jason&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Nov 2010 22:11:37 GMT</pubDate>
    <dc:creator>JasonLevine</dc:creator>
    <dc:date>2010-11-10T22:11:37Z</dc:date>
    <item>
      <title>Activating the mapClick function through a component.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165399#M3861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I've created a simple map (not the sample viewer) with the ability to identify a layer and added four buttons through a component.&amp;nbsp; The first three buttons are Zoom In, Zoom Out, and Pan.&amp;nbsp; I'd like the fourth button to activate the Identify tool by setting the mapClick function of the main map (myMap).&amp;nbsp; I don't want the identify function to always be active, but im not sure how to activate it with my identify function, and then deactivate it when one of the other buttons are clicked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here is my main.mxml:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:s="library://ns.adobe.com/flex/spark"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:esri="http://www.esri.com/2008/ags"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:components="components.*"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pageTitle="Identify Features on the Map"&amp;gt;
 &amp;lt;!--
 This sample shows how to identify features with a MapClick and the Identify task.
 
 The IdentifyParameters designate which layers are being identified.
 Identify operations can potentially return a lot of information
 depending on the number of layers being identified and a given tolerance.
 The tolerance is the number of pixels a feature is allowed to lie away
 from the clicked point in order to be counted as a result.
 
 In this sample, when user clicks the map, an "Identify" task is executed.
 
 When the task finishes executing, the executeCompleteHandler function loops
 through the features in the IdentifyResult and adds them to the map.
 --&amp;gt;
 &amp;lt;fx:Script&amp;gt;
&amp;nbsp; &amp;lt;![CDATA[
&amp;nbsp;&amp;nbsp; import com.esri.ags.Graphic;
&amp;nbsp;&amp;nbsp; import com.esri.ags.events.MapMouseEvent;
&amp;nbsp;&amp;nbsp; import com.esri.ags.geometry.Geometry;
&amp;nbsp;&amp;nbsp; import com.esri.ags.symbols.InfoSymbol;
&amp;nbsp;&amp;nbsp; import com.esri.ags.tasks.supportClasses.IdentifyParameters;
&amp;nbsp;&amp;nbsp; import com.esri.ags.tasks.supportClasses.IdentifyResult;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; import mx.controls.Alert;
&amp;nbsp;&amp;nbsp; import mx.rpc.AsyncResponder;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; [Bindable]private var lastIdentifyResultGraphic:Graphic;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; private function mapClickHandler(event:MapMouseEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; clickGraphicsLayer.clear();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var identifyParams:IdentifyParameters = new IdentifyParameters();
&amp;nbsp;&amp;nbsp;&amp;nbsp; identifyParams.returnGeometry = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp; identifyParams.tolerance = 3;
&amp;nbsp;&amp;nbsp;&amp;nbsp; identifyParams.width = myMap.width;
&amp;nbsp;&amp;nbsp;&amp;nbsp; identifyParams.height = myMap.height;
&amp;nbsp;&amp;nbsp;&amp;nbsp; identifyParams.geometry = event.mapPoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp; identifyParams.mapExtent = myMap.extent;
&amp;nbsp;&amp;nbsp;&amp;nbsp; identifyParams.spatialReference = myMap.spatialReference;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var clickGraphic:Graphic = new Graphic(event.mapPoint, clickPtSym);
&amp;nbsp;&amp;nbsp;&amp;nbsp; clickGraphicsLayer.add(clickGraphic);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; identifyTask.execute(identifyParams, new AsyncResponder(myResultFunction, myFaultFunction, clickGraphic));
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; private function myResultFunction(results:Array, clickGraphic:Graphic = null):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (results &amp;amp;&amp;amp; results.length &amp;gt; 0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var result:IdentifyResult = results[0];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var resultGraphic:Graphic = result.feature;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch (resultGraphic.geometry.type)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case Geometry.MAPPOINT:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resultGraphic.symbol = smsIdentify;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case Geometry.POLYLINE:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resultGraphic.symbol = slsIdentify;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case Geometry.POLYGON:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resultGraphic.symbol = sfsIdentify;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lastIdentifyResultGraphic = resultGraphic;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // update clickGraphic (from mouse click to returned feature)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clickGraphic.symbol = new InfoSymbol(); // use default renderer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clickGraphic.attributes = resultGraphic.attributes;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; private function myFaultFunction(error:Object, clickGraphic:Graphic = null):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show(String(error), "Identify Error");
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; ]]&amp;gt;
 &amp;lt;/fx:Script&amp;gt;
 
 &amp;lt;fx:Declarations&amp;gt;
&amp;nbsp; &amp;lt;esri:NavigationTool id="navTool" map="{myMap}"/&amp;gt;
&amp;nbsp; 
&amp;nbsp; &amp;lt;!-- Symbol for where the user clicked --&amp;gt;
&amp;nbsp; &amp;lt;esri:SimpleMarkerSymbol id="clickPtSym"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; color="0xFF0000"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; size="12"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; style="x"/&amp;gt;
&amp;nbsp; 
&amp;nbsp; &amp;lt;!-- Symbol for Identify Result as Polyline --&amp;gt;
&amp;nbsp; &amp;lt;esri:SimpleLineSymbol id="slsIdentify"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; width="2"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alpha="1"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; color="0x00FF00"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; style="solid"/&amp;gt;
&amp;nbsp; 
&amp;nbsp; &amp;lt;!-- Symbol for Identify Result as Point --&amp;gt;
&amp;nbsp; &amp;lt;esri:SimpleMarkerSymbol id="smsIdentify"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; color="0x00FF00"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; size="15"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; style="diamond"/&amp;gt;
&amp;nbsp; 
&amp;nbsp; &amp;lt;!-- Symbol for Identify Result as Polygon --&amp;gt;
&amp;nbsp; &amp;lt;esri:SimpleFillSymbol id="sfsIdentify"/&amp;gt;
&amp;nbsp; 
&amp;nbsp; &amp;lt;!-- Identify Task --&amp;gt;
&amp;nbsp; &amp;lt;esri:IdentifyTask id="identifyTask"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; concurrency="last"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer"/&amp;gt;
 &amp;lt;/fx:Declarations&amp;gt;
 
 &amp;lt;esri:Map id="myMap"
&amp;nbsp; &amp;lt;esri:extent&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;esri:WebMercatorExtent minlon="-120" minlat="30" maxlon="-100" maxlat="50"/&amp;gt;
&amp;nbsp; &amp;lt;/esri:extent&amp;gt;
&amp;nbsp; &amp;lt;esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/&amp;gt;
&amp;nbsp; &amp;lt;esri:GraphicsLayer graphicProvider="{lastIdentifyResultGraphic}"/&amp;gt;
&amp;nbsp; &amp;lt;esri:GraphicsLayer id="clickGraphicsLayer"/&amp;gt;
 &amp;lt;/esri:Map&amp;gt;
 &amp;lt;components:buttons left="10" navTool="{navTool}" myMap="{myMap}"/&amp;gt;

 
&amp;lt;/s:Application&amp;gt;
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And here is my buttons.mxml component:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
&amp;nbsp;&amp;nbsp; xmlns:s="library://ns.adobe.com/flex/spark" 
&amp;nbsp;&amp;nbsp; xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"&amp;gt;

 &amp;lt;fx:Script&amp;gt;
&amp;nbsp; &amp;lt;![CDATA[
&amp;nbsp;&amp;nbsp; import com.esri.ags.Map;
&amp;nbsp;&amp;nbsp; public var myMap:Map;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; import com.esri.ags.tools.NavigationTool;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; public var navTool:NavigationTool;
&amp;nbsp; ]]&amp;gt;
 &amp;lt;/fx:Script&amp;gt;
 &amp;lt;fx:Declarations&amp;gt;
&amp;nbsp; &amp;lt;!-- Place non-visual elements (e.g., services, value objects) here --&amp;gt;
 &amp;lt;/fx:Declarations&amp;gt;
&amp;lt;s:HGroup&amp;gt;
 &amp;lt;s:Button label="Zoom In" click="navTool.activate(NavigationTool.ZOOM_IN)"/&amp;gt;
 &amp;lt;s:Button label="Zoom Out" click="navTool.activate(NavigationTool.ZOOM_OUT)"/&amp;gt;
 &amp;lt;s:Button label="Pan" click="navTool.activate(NavigationTool.PAN)"/&amp;gt;
 &amp;lt;s:Button label="Identify" click="WHAT DO I PLACE HERE TO SET THE MAPCLICK FOR myMap?"/&amp;gt;
&amp;lt;/s:HGroup&amp;gt;
&amp;lt;/s:Group&amp;gt;
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jason&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Nov 2010 19:03:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165399#M3861</guid>
      <dc:creator>JasonLevine</dc:creator>
      <dc:date>2010-11-10T19:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Activating the mapClick function through a component.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165400#M3862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;While I don't know enough about scope in Flex to know if this will work from your external buttons.mxml, I think I would use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;myMap.addEventListener(MapMouseEvent.MAP_CLICK,mapClickHandler);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then you could put the reverse in the clickHandler for one of the other buttons:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;myMap.removeEventListener(MapMouseEvent.MAP_CLICK,mapClickHandler);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Nov 2010 21:05:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165400#M3862</guid>
      <dc:creator>DavidElies</dc:creator>
      <dc:date>2010-11-10T21:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Activating the mapClick function through a component.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165401#M3863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If I understand you right, what you'd probably want to do is add an EventListener to the Map on that button click.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
// For arguments sake, let's say a user clicks the Identify button twice.
// Call your remove function before adding another listener
removeMapListener(); // you can reuse this function for each of your other button clicks
map.addEventListener(MapMouseEvent.MAP_CLICK, onMapClicked_handler);

protected function onMapClicked_handler(event:MapMouseEvent):void {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // grab your event.mapPoint and use it for your Identify tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; // you can call removeMapListener() again if you'd like
}

protected function removeMapListener():void {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (map.hasEventListener(MapMouseEvent.MAP_CLICK))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.removeEventListener(MapMouseEvent.MAP_CLICK, onMapClicked_handler);
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think that makes sense, and that's similar to how I handle it for my Identify Tool.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:38:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165401#M3863</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-11T08:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: Activating the mapClick function through a component.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165402#M3864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Rene,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I understand using the event listener for the map click, but how do I call the mapClickHandler function (the identify function) in the Main.mxml from the event listener in the buttons.mxml?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jason&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Nov 2010 22:11:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165402#M3864</guid>
      <dc:creator>JasonLevine</dc:creator>
      <dc:date>2010-11-10T22:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Activating the mapClick function through a component.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165403#M3865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is probably how I would handle it. You can create one function to capture all the button clicks and let that function handle what happens. You can also make sure the Identify Task will not fire when you just want to zoom or pan.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;lt;fx:Script&amp;gt;
 &amp;lt;![CDATA[
&amp;nbsp; protected static const IDENTIFY:String = "identify";
&amp;nbsp; 
&amp;nbsp; protected function activateIdentify():void {
&amp;nbsp;&amp;nbsp; map.addEventListener(MapMouseEvent.MAP_CLICK, onMapClicked_handler);
&amp;nbsp; }
&amp;nbsp; 
&amp;nbsp; protected function onMapClicked_handler(event:MapMouseEvent):void {
&amp;nbsp;&amp;nbsp; var idParams:IdentifyParameters = new IdentifyParameters();
&amp;nbsp;&amp;nbsp; idParams.layerIds = [layerId];
&amp;nbsp;&amp;nbsp; idParams.tolerance = 2;
&amp;nbsp;&amp;nbsp; idParams.returnGeometry = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // grab your event.mapPoint and use it for your Identify tool
&amp;nbsp;&amp;nbsp; idParams.geometry = event.mapPoint; 
&amp;nbsp;&amp;nbsp; idParams.width = _map.width;
&amp;nbsp;&amp;nbsp; idParams.height = _map.height;
&amp;nbsp;&amp;nbsp; idParams.mapExtent = _map.extent;
&amp;nbsp;&amp;nbsp; idParams.spatialReference = _map.spatialReference;
&amp;nbsp;&amp;nbsp; idParams.layerOption = "all";
&amp;nbsp;&amp;nbsp; var idSym:SimpleMarkerSymbol = new SimpleMarkerSymbol("x", 12, 0xFF0000);
&amp;nbsp;&amp;nbsp; var g:Graphic = new Graphic(event.mapPoint, idSym);
&amp;nbsp;&amp;nbsp; // idLayer is a graphicsLayer I use to
&amp;nbsp;&amp;nbsp; // just show where I clicked on the map
&amp;nbsp;&amp;nbsp; idLayer.clear();
&amp;nbsp;&amp;nbsp; idLayer.add(g);

&amp;nbsp;&amp;nbsp; idTask.url = "urlForIdentifyTaskToUse";

&amp;nbsp;&amp;nbsp; idTask.execute(idParams, new AsyncResponder(onIdentifyResults_handler, onFault, g));
&amp;nbsp; }

&amp;nbsp; protected function removeMapListener():void {
&amp;nbsp;&amp;nbsp; if (map.hasEventListener(MapMouseEvent.MAP_CLICK))
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.removeEventListener(MapMouseEvent.MAP_CLICK, onMapClicked_handler);
&amp;nbsp; }
&amp;nbsp; 
&amp;nbsp; protected function navigate(type:String):void {
&amp;nbsp;&amp;nbsp; removeMapListener(); // you can reuse this function for each of your other button clicks
&amp;nbsp;&amp;nbsp; switch(type) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; case NavigationTool.ZOOM_IN:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; navTool.activate(NavigationTool.ZOOM_IN);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp; case NavigationTool.ZOOM_OUT:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; navTool.activate(NavigationTool.ZOOM_OUT);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp; case NavigationTool.PAN:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; navTool.activate(NavigationTool.PAN);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp; case IDENTIFY:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activateIdentify();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }
 ]]&amp;gt;
&amp;lt;/fx:Script&amp;gt;
&amp;lt;s:HGroup&amp;gt;
 &amp;lt;s:Button label="Zoom In" click="navigate(NavigationTool.ZOOM_IN)"/&amp;gt;
 &amp;lt;s:Button label="Zoom Out" click="navigate(NavigationTool.ZOOM_OUT)"/&amp;gt;
 &amp;lt;s:Button label="Pan" click="navigate(NavigationTool.PAN)"/&amp;gt;
 &amp;lt;s:Button label="Identify" click="navigate(IDENTIFY)"/&amp;gt;
&amp;lt;/s:HGroup&amp;gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:38:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165403#M3865</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-11T08:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Activating the mapClick function through a component.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165404#M3866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Rene,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; I sort of see what you're suggesting.&amp;nbsp; You moved the entire identify function over to the buttons.mxml.&amp;nbsp; I'll have to bind all of the graphics layers over to my main.mxml.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;when you say "// grab your event.mapPoint and use it for your Identify tool", what do you mean, and how do I do that?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jason&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Nov 2010 15:48:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165404#M3866</guid>
      <dc:creator>JasonLevine</dc:creator>
      <dc:date>2010-11-12T15:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Activating the mapClick function through a component.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165405#M3867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry, I meant to remove those comments. You just need to use the event.mapPoint as the geometry for your IdentifyParameters you send to your IdentifyTask.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/tasks/supportClasses/IdentifyParameters.html"&gt;http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/tasks/supportClasses/IdentifyParameters.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;idParams.geometry = event.mapPoint;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Nov 2010 17:13:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165405#M3867</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2010-11-12T17:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Activating the mapClick function through a component.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165406#M3868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your help with this Rene, I got it working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Jason&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Nov 2010 16:21:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/activating-the-mapclick-function-through-a/m-p/165406#M3868</guid>
      <dc:creator>JasonLevine</dc:creator>
      <dc:date>2010-11-16T16:21:10Z</dc:date>
    </item>
  </channel>
</rss>

