I did something similar for one of my maps with query results and clicking on a page element to show the infoWindow so my method might be similar to what you are looking for. Does the index of your graphic layer match the index of your drop down list? If it does, you should be able to use the index to tap into the geometry of the point to show your infoWindow. The code would be something like this:function reveal_site(i){point = gmarkers.geometry;point = esri.geometry.geographicToWebMercator(point);map.infoWindow.setTitle(gmarkers.getTitle());map.infoWindow.setContent(gmarkers.getContent());map.infoWindow.show(point, point);}This is similar to what you have, but your code is triggered by a click event on the map while you want it to fire when something from the dropdown menu is selected. You should be able to call the function from the dropdown menu and use the index to decide which point to show the infoWindow for. Just be careful with your variable declarations- the gmarker variable may need to be global to work in this case. Also not sure how your graphics layer is set up exactly - I was using results from a query when I did this so the geometry of the points was returned. If I understand your file right, you may need to use the lat and long fields in place of the geometry.If this seems like it might be promising, I can try to go into more detail. Good luck, hope this is helpful!
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()); map.infoWindow.show(point, point); } }
dojo.connect(map, "onClick", function(evt) { if(map.infoWindow.isShowing) { map.infoWindow.hide(); } click_handle = true; var g = evt.graphic; map.infoWindow.setContent(g.getContent()); map.infoWindow.setTitle(g.getTitle()); map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint)); });
graphic = new esri.Graphic(point, icon, attr, siteTemplate); glayer.add(graphic); gmarkers[nm] = graphic; nm++;
<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">Graphic 0</option> <option value="1">Graphic 1</option> <option value="2">Graphic 2</option> </select> </form>
function reveal_site(i) { dojo.connect(map, "onClick", function(evt) { if(map.infoWindow.isShowing) { map.infoWindow.hide(); } click_handle = true; var g = evt.graphic; map.infoWindow.setContent(g.getContent()); map.infoWindow.setTitle(g.getTitle()); map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint)); }); }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.