lowrytjr

Programmatically trigger infoWindow for KML layer

Discussion created by lowrytjr on Jul 17, 2012
Latest reply on Jul 17, 2012 by DSwingley-esristaff
I have a map that I am creating as follows:

var map;
var kmlLayers;
var initExtent = new esri.geometry.Extent({ "xmin": -126.95, "ymin": 21.08, "xmax": -60.24, "ymax": 49.86, "spatialReference": { "wkid": 4326} });
var popup = new esri.dijit.Popup(null, dojo.create("div"));

map = new esri.Map("map", { extent: esri.geometry.geographicToWebMercator(initExtent), "infoWindow": popup });                                
dojo.place(popup.domNode, map.root);

var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);

var kmlTownshipUrl = 'http://myServer.net/KML/myKML.kml';
var newKMLLayer = new kmlLayer(kmlTownshipUrl);
newKMLLayer.addLayerToMap(map);
kmlLayers.push(newKMLLayer);


The layer loads just fine, and when I click on it, I get the infoWindow with the approriate name and description fields from the <Placemark> in the KML. I then use my kmlLayers array to call the .hide() and .show() methods when a user checks/unchecks a box, and all works just fine.

What I want to do is programmatically show the infoWindow as well, but as yet have had no success. In order to get the infoWindow to show properly, I have to actually click on it. Has anyone encountered this, and have a solution? Maybe I need to manage the infoWindow data independently of the KML? Any ideas would be helpful. Thanks.

Outcomes