<?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: Opening infoWindow by clicking on a point vs. selecting point from dropdown box in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/opening-infowindow-by-clicking-on-a-point-vs/m-p/509766#M47381</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes. This solution works great. Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Aug 2013 14:21:59 GMT</pubDate>
    <dc:creator>RayJulich</dc:creator>
    <dc:date>2013-08-06T14:21:59Z</dc:date>
    <item>
      <title>Opening infoWindow by clicking on a point vs. selecting point from dropdown box</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/opening-infowindow-by-clicking-on-a-point-vs/m-p/509764#M47379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a map (&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://wa.water.usgs.gov/projects/puyallupmonitoring/hydrographs.htm" rel="nofollow" target="_blank"&gt;http://wa.water.usgs.gov/projects/puyallupmonitoring/hydrographs.htm&lt;/A&gt;&lt;SPAN&gt;) where a user can click on a point on the map to open it's infoWindow or he/she can select a point from a dropdown box on the top of the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I add the points to the map, I read in information from a file and add each point to an array:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var gmarkers = []; //Array of all the markers var nm = 0;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the loop:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;... siteTemplate = new esri.InfoTemplate(title,info); attr = {WELL_NO: site_name}; graphic = new esri.Graphic(point, icon, attr, siteTemplate); map.infoWindow.resize(500, 400); glayer.add(graphic); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gmarkers[nm] = graphic; nm++; ...&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my dropdown menu I have call a function and pass in an array index and the latitude and longitude of the point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;lt;form style="margin-top:2px;margin-bottom:10px;" action=""&amp;gt;&amp;nbsp; &amp;lt;select name="delta" onchange="javascript:reveal_site(delta.value)"&amp;gt; &amp;nbsp; &amp;lt;option value=""&amp;gt;Select a well&amp;lt;/option&amp;gt; &amp;nbsp; &amp;lt;option value="0,47.076611,-122.127667"&amp;gt;18N/05E-02H02&amp;lt;/option&amp;gt; &amp;nbsp; &amp;lt;option value="1,47.078417,-122.170528"&amp;gt;18N/05E-04A01&amp;lt;/option&amp;gt; &amp;nbsp; &amp;lt;option value="2,47.076667,-122.195861"&amp;gt;18N/05E-05G03&amp;lt;/option&amp;gt; &amp;nbsp; &amp;lt;option value="3,47.081361,-122.212056"&amp;gt;18N/05E-06A02&amp;lt;/option&amp;gt; &amp;nbsp; &amp;lt;option value="4,47.064722,-122.207417"&amp;gt;18N/05E-08D06&amp;lt;/option&amp;gt; ...&amp;nbsp; &amp;lt;/select&amp;gt; &amp;lt;/form&amp;gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The function that's called:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function reveal_site(i)&amp;nbsp; {&amp;nbsp; var split = i.split(',');&amp;nbsp; var index = split[0];&amp;nbsp; var latitude = split[1];&amp;nbsp; var longitude = split[2];&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(index)&amp;nbsp; { &amp;nbsp; point = new esri.geometry.Point(longitude,latitude,new esri.SpatialReference({ wkid: 4326 })); &amp;nbsp; point = esri.geometry.geographicToWebMercator(point); &amp;nbsp; map.infoWindow.setTitle(gmarkers[index].getTitle()); &amp;nbsp; map.infoWindow.setContent(gmarkers[index].getContent()); &amp;nbsp; map.infoWindow.show(point, point);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that when a point is selected from the dropdown menu, sometimes it displays the wrong infoWindow, but it always it displayed in the correct location though. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is what I get when clicking on this particular point:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]26405[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I select the same station number from the dropdown menu, I get a different infoWindow at the same point on the map:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]26406[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems that when read in the points from a file and add them to the array, they aren't being put into the array linearly. For example: the 2nd point in the file is sometimes the 3rd item in the array.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Aug 2013 15:45:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/opening-infowindow-by-clicking-on-a-point-vs/m-p/509764#M47379</guid>
      <dc:creator>RayJulich</dc:creator>
      <dc:date>2013-08-02T15:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Opening infoWindow by clicking on a point vs. selecting point from dropdown box</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/opening-infowindow-by-clicking-on-a-point-vs/m-p/509765#M47380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think this is more of a javascript problem than an ESRI one. If I were you, I would change the way you keep track of your wells. Instead of using an index in an array, maybe you could try using a dictionary and organizing by well name? (I'm assuming that the name you're using in your dropdown selection is the well name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var gmarkers = {};&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;gmarkers[site_name] = graphic;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And then when you click an item in the dropdown menu, you can use the site name instead of the selection index, since the selection index doesn't always correspond to the right value in the gmarker array. Additionally, since gmarkers is just full of graphics, you can get the graphic's geometry property to get the point that you need, rather than having to populate your option list with it and parse it from there. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;lt;form style="margin-top:2px;margin-bottom:10px;" action=""&amp;gt;&amp;nbsp; &amp;lt;select name="delta" onchange="javascript:reveal_site(this)"&amp;gt; &amp;nbsp; &amp;lt;option value=""&amp;gt;Select a well&amp;lt;/option&amp;gt; &amp;nbsp; &amp;lt;option value="0,47.076611,-122.127667"&amp;gt;18N/05E-02H02&amp;lt;/option&amp;gt; &amp;nbsp; &amp;lt;option value="1,47.078417,-122.170528"&amp;gt;18N/05E-04A01&amp;lt;/option&amp;gt; &amp;nbsp; &amp;lt;option value="2,47.076667,-122.195861"&amp;gt;18N/05E-05G03&amp;lt;/option&amp;gt; &amp;nbsp; &amp;lt;option value="3,47.081361,-122.212056"&amp;gt;18N/05E-06A02&amp;lt;/option&amp;gt; &amp;nbsp; &amp;lt;option value="4,47.064722,-122.207417"&amp;gt;18N/05E-08D06&amp;lt;/option&amp;gt; ...&amp;nbsp; &amp;lt;/select&amp;gt; &amp;lt;/form&amp;gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function reveal_site(i)&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var site_name = i.options[d.selectedIndex].innerHTML; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var gmarker = gmarkers[site_name]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var point = gmarker.geometry; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point = esri.geometry.geographicToWebMercator(point);&amp;nbsp; map.infoWindow.setTitle(gmarker.getTitle());&amp;nbsp; map.infoWindow.setContent(gmarker.getContent());&amp;nbsp; map.infoWindow.show(point, point);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope that this makes sense and helps you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Aug 2013 19:28:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/opening-infowindow-by-clicking-on-a-point-vs/m-p/509765#M47380</guid>
      <dc:creator>CameronMacNeil</dc:creator>
      <dc:date>2013-08-02T19:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Opening infoWindow by clicking on a point vs. selecting point from dropdown box</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/opening-infowindow-by-clicking-on-a-point-vs/m-p/509766#M47381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes. This solution works great. Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 14:21:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/opening-infowindow-by-clicking-on-a-point-vs/m-p/509766#M47381</guid>
      <dc:creator>RayJulich</dc:creator>
      <dc:date>2013-08-06T14:21:59Z</dc:date>
    </item>
  </channel>
</rss>

