AnsweredAssumed Answered

Opening infoWindow by clicking on a point vs. selecting point from dropdown box

Question asked by rjulich on Aug 2, 2013
Latest reply on Aug 6, 2013 by rjulich
I have a map ( 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.

When I add the points to the map, I read in information from a file and add each point to an array:
var gmarkers = []; //Array of all the markers var nm = 0;

In the loop:
... 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);      gmarkers[nm] = graphic; nm++; ...

In my dropdown menu I have call a function and pass in an array index and the latitude and longitude of the point.

<form style="margin-top:2px;margin-bottom:10px;" action="">  <select name="delta" onchange="javascript:reveal_site(delta.value)">   <option value="">Select a well</option>   <option value="0,47.076611,-122.127667">18N/05E-02H02</option>   <option value="1,47.078417,-122.170528">18N/05E-04A01</option>   <option value="2,47.076667,-122.195861">18N/05E-05G03</option>   <option value="3,47.081361,-122.212056">18N/05E-06A02</option>   <option value="4,47.064722,-122.207417">18N/05E-08D06</option> ...  </select> </form>

The function that's called:
function reveal_site(i)  {  var split = i.split(',');  var index = split[0];  var latitude = split[1];  var longitude = split[2];        if(index)  {   point = new esri.geometry.Point(longitude,latitude,new esri.SpatialReference({ wkid: 4326 }));   point = esri.geometry.geographicToWebMercator(point);   map.infoWindow.setTitle(gmarkers[index].getTitle());   map.infoWindow.setContent(gmarkers[index].getContent());, point);       } }

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.

Here is what I get when clicking on this particular point:

When I select the same station number from the dropdown menu, I get a different infoWindow at the same point on the map:

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.