<?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: Programmatically fire map's click event in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685798#M63843</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp; Thanks for documenting this! It's crucial to my app and I couldn't find this information anywhere else.&lt;/P&gt;&lt;P&gt;&amp;nbsp; As you say, it's not clear why you need to provide a screen point and a map point, but you can use map.toScreen(mapPoint) and map.toMap(screenPoint) to convert either one to the other.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Sep 2014 14:58:34 GMT</pubDate>
    <dc:creator>deleted-user-FwGV4nJuPxiQ</dc:creator>
    <dc:date>2014-09-11T14:58:34Z</dc:date>
    <item>
      <title>Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685789#M63834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the Esri's Javascript API 3.9. I have created functionality that allows a user to add a graphic to the map by clicking on the map. The type of graphic added depends on some previous selection that user has made. For example, selecting one option (say Option A) adds a circle graphic whereas selecting a different option (say Option B) adds a square graphic.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My need for the programmatic map 'click' event is with the automated unit tests I am creating (I am using Jasmine for my unit tests). My hope is to write a unit test which selects programmatically Option A, programmatically triggers a click on the map, and verifies that the correct 'map click' event handler was called (the one that handles the map clicks when Option A is selected).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried using dojo's emit function.&amp;nbsp; The code seems to execute with no errors, i.e. the function call returns an 'event' object, but no map click event handler is ever called. I am pretty sure the event is hooked up correctly because if I follow those same steps manually, the correct event handler is called. As part of my testing, i have tried passing the 'emit' function both the map object and the div which contains the map object. Neither way seems to work, i.e. the click event handler is not called. Its not critical to my testing that a 'correct' argument is passed to the event handler; i just want to know that the correct handler is called.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, my question is how can i programmatically fire/trigger a map's click event?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//relevant code&lt;/P&gt;&lt;P&gt;this.map = new Map(divId, {&lt;/P&gt;&lt;P&gt;&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; basemap: "streets",&lt;/P&gt;&lt;P&gt;&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; center: [-122, 45.6],&lt;/P&gt;&lt;P&gt;&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; zoom: 5,&lt;/P&gt;&lt;P&gt;&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; smartNavigation: false&lt;/P&gt;&lt;P&gt;&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; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//passing the div which contains the map&lt;/P&gt;&lt;P&gt;var theMapDiv = dom.byId(divId);&lt;/P&gt;&lt;P&gt;var testEvent = on.emit(theMapDiv, "click", { bubbles: true, cancelable: true });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//passing the map&lt;/P&gt;&lt;P&gt;var testEvent = on.emit(this.map, "click", { bubbles: true, cancelable: true });&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2014 21:49:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685789#M63834</guid>
      <dc:creator>TomRippetoe</dc:creator>
      <dc:date>2014-07-22T21:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685790#M63835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have no experience with Jasmine, but I have done similar testing using &lt;A href="http://www.seleniumhq.org/"&gt;Selenium&lt;/A&gt;‌. This is a great framework for simulating user input and interaction.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 03:16:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685790#M63835</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2014-07-23T03:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685791#M63836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Stephen.&amp;nbsp; I did a quick peek at Selenium and that might get me down the right path with its functionality to record user interactions. I will post back and let you know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am still hoping that there is some way, outside of a testing framework, to programmatically trigger a map click event (or any other map event i suppose).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 15:57:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685791#M63836</guid>
      <dc:creator>TomRippetoe</dc:creator>
      <dc:date>2014-07-23T15:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685792#M63837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thomas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's another potential approach: &lt;A href="http://stackoverflow.com/a/16509592/906814" title="http://stackoverflow.com/a/16509592/906814"&gt;jquery - How to simulate a click by using x,y coordinates in JavaScript? - Stack Overflow&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(where the XY would be page coordinates over the map). I haven't tested this......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 23:44:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685792#M63837</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2014-07-23T23:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685793#M63838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stephen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for the tip.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried both approaches described in the Stack Overflow question you linked to......without any good luck for either one.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suspect the challenge is to know which piece of the 'overall map' is emitting the click event in the real world - is it the container, one of the layers, etc.&amp;nbsp; Once i figure that out, i can have that particular element programmatically trigger the event?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll keep poking around.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 17:04:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685793#M63838</guid>
      <dc:creator>TomRippetoe</dc:creator>
      <dc:date>2014-07-24T17:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685794#M63839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was able to figure this out. It turns out that dojo adds an 'emit' function to javascript objects. Instead of using 'on.emit()' I just called 'object.emit()'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The old, not working code:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;var testEvent = on.emit(this.map, "click", { bubbles: true, cancelable: true });&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The new, working code:&lt;/P&gt;&lt;P&gt;this.map.emit("click", &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;{ bubbles: true, cancelable: true });&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 19:28:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685794#M63839</guid>
      <dc:creator>TomRippetoe</dc:creator>
      <dc:date>2014-07-24T19:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685795#M63840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excellent - I'm glad you figured it out!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 23:14:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685795#M63840</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2014-07-24T23:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685796#M63841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do you specify the click location with &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;map.emit("click", { bubbles: true, cancelable: true });&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Aug 2014 16:17:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685796#M63841</guid>
      <dc:creator>JeffPace</dc:creator>
      <dc:date>2014-08-08T16:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685797#M63842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jeff.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can 'value add' a 'mapPoint' and/or 'screenPoint' objects to the click event. I think 'mapPoint' might be the object you are looking for. I have done something like this (I am pretty sure that i am not doing&amp;nbsp; 'screenPoint' correctly - that's why i am using mapPoint):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var scrPt = new Point(-122, 45.6);&lt;/P&gt;&lt;P&gt;var mpPt = new Point(-122, 45.6);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;map.emit("click", { bubbles: true, cancelable: true, screenPoint: scrPt, mapPoint: mpPt });&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Aug 2014 17:48:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685797#M63842</guid>
      <dc:creator>TomRippetoe</dc:creator>
      <dc:date>2014-08-11T17:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685798#M63843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp; Thanks for documenting this! It's crucial to my app and I couldn't find this information anywhere else.&lt;/P&gt;&lt;P&gt;&amp;nbsp; As you say, it's not clear why you need to provide a screen point and a map point, but you can use map.toScreen(mapPoint) and map.toMap(screenPoint) to convert either one to the other.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Sep 2014 14:58:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685798#M63843</guid>
      <dc:creator>deleted-user-FwGV4nJuPxiQ</dc:creator>
      <dc:date>2014-09-11T14:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685799#M63844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. This was helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2015 16:19:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685799#M63844</guid>
      <dc:creator>deleted-user-YYhuCJuuEn9L</dc:creator>
      <dc:date>2015-04-06T16:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685800#M63845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This was an awesome start to my solution, thanks so much!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I needed to generate a click based on a specific point. For example the current map center, like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;//Get the map center point that outputs an object with: type (point), x, y, and spatialReference&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;var currentMapCenter = map.getExtent().getCenter();&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;//Emulate a click on the map center point&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;map.emit("click", { mapPoint: currentMapCenter&amp;nbsp;});&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jul 2017 15:21:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685800#M63845</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-07-12T15:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically fire map's click event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685801#M63846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does anyone have any advice for how to fire a click event programmatically in the 4.x version of the API? It looks like the map.event method is no longer available.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My goal is to be able to select a feature on a MapImageLayer programmatically, and have it's corresponding popup display as if it had been clicked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts would be much appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2018 17:44:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programmatically-fire-map-s-click-event/m-p/685801#M63846</guid>
      <dc:creator>NathanielRindlaub</dc:creator>
      <dc:date>2018-05-23T17:44:59Z</dc:date>
    </item>
  </channel>
</rss>

