AnsweredAssumed Answered

Interaction of CSVLayer and KMLLayer

Question asked by ejh001 on Feb 23, 2016

I have a map where I have a KMLLayer that defines a geographic boundary and a CSVLayer that defines points within that boundary. I do not want any infoWindow information popping up for the KMLLayer and want to take some actions on the click event on the CSVLayer.


In building this page, I have found that I can no longer apply a click event to the CSVLayer once I have added the KMLLayer to the map.


Seems like it would not be too difficult... but I have played with multiple instances of this and keep coming back to the same place.


Any help appreciated.


var map, kml, csv;
            require(["esri/map", "esri/layers/KMLLayer", "esri/layers/CSVLayer", "esri/renderers/SimpleRenderer", "esri/InfoTemplate", "esri/urlUtils", "esri/symbols/PictureMarkerSymbol", "esri/geometry/Point", "esri/SpatialReference", "esri/geometry/webMercatorUtils", "esri/geometry/screenUtils", "esri/geometry/ScreenPoint", "dojo/dom", "dojo/_base/array", "dojo/domReady!"], function(Map, KMLLayer, CSVLayer, SimpleRenderer, InfoTemplate, urlUtils, PictureMarkerSymbol, Point, SpatialReference, webMercatorUtils, screenUtils, ScreenPoint, dom, array) {
                map = new Map("map", {
                    basemap : "hybrid",
                    center : [-83.71, 36.05],
                    zoom : 8

                map.on("load", function() {
                    map.infoWindow.set('anchor', 'bottom-right');
                    map.infoWindow.resize(625, 425);
                map.infoWindow.on("hide", centerMap);

                    proxyUrl : "/proxy/proxy.php",
                    urlPrefix : ""

                var template = new InfoTemplate("${name}", "<iframe src=${fcstlink} class="fcst"></iframe>");
                var csvUrl = "";
                csv = new CSVLayer(csvUrl, {
                    copyright : "",
                    infoTemplate : template
                var logo = new PictureMarkerSymbol("", 20, 20);
                var renderer = new SimpleRenderer(logo);
                csv.on("click", mapFcstAction);

                var kmlUrl = "";
                kml = new KMLLayer(kmlUrl);

                kml.on('load', function(lyr) {
                    var layers = lyr.layer.getLayers();
                    array.forEach(layers, function(l) {

                function centerMap() {
                    map.centerAt([-83.71, 36.05]);

                function mapFcstAction(evt) {
                    var screenX = evt.screenPoint.x;
                    var screenY = evt.screenPoint.y;
                    var newScreenX = screenX + 225;
                    var newScreenY = screenY + 250;
                    var newScreenCenter = screenUtils.toMapPoint(map.extent, 800, 550, new ScreenPoint(newScreenX, newScreenY));