I am trying to create a pop up window when I click on a feature included in my map that displays their attributes. I want it to apply to all visible layers. So far this is a working section of code I have:
//Assume that map is your map object var idTask1, idTask2, idParams = new esri.tasks.IdentifyParameters(); var url1 = "", var url2 = ""; dojo.connect(map, "onLoad", initIdentifies); function initIdentifies(map) { //map.onLoad passes in the map object idTask1 = new esri.tasks.IdentifyTask(url1); idTask2 = new esri.tasks.IdentifyTask(url2); //A few sample constant parameters. Set more or less as you need idParams.tolerance = 12; idParams.returnGeometry = true; idParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; dojo.connect(map, "onClick", runIdentifies); } function runIdentifies(evt) { var defTask1 = new dojo.Deferred(), defTask2 = new dojo.Deferred; var dlTasks = new dojo.DeferredList([defTask1, defTask2]); dlTasks.then(showResults); //defTasks will fire after defTask1 and defTask2 have completed //These parameters change with each request idParams.width = map.width; idParams.height = map.height; idParams.geometry = evt.mapPoint; idParams.mapExtent = map.extent; try { idTask1.execute(idParams, defTask1.callback, defTask1.errback); //Pass the response into the callback on defTask1 } catch (e) { console.log("Error caught"); console.log(e); defTask1.errback(e); //If you get an error, execute the errback } try { idTask2.execute(idParams, defTask2.callback, defTask2.errback); //Pass the response into the callback on defTask2 } catch (e) { console.log("Error caught"); console.log(e); defTask2.errback(e); //If you get an error, execute the errback } } function showResults(r) { //The format of 'r' is [[Boolean task 1 success, [task 1 results]],[Boolean task 2 success, [task 2 results]]] //using the array 'r', build and show your infoWindow as normal } I created an alert with the value 'r' for each event triggered, and the alert window worked. I just need the code to build the pop up window populated by the array.
أكثر...
//Assume that map is your map object var idTask1, idTask2, idParams = new esri.tasks.IdentifyParameters(); var url1 = "", var url2 = ""; dojo.connect(map, "onLoad", initIdentifies); function initIdentifies(map) { //map.onLoad passes in the map object idTask1 = new esri.tasks.IdentifyTask(url1); idTask2 = new esri.tasks.IdentifyTask(url2); //A few sample constant parameters. Set more or less as you need idParams.tolerance = 12; idParams.returnGeometry = true; idParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; dojo.connect(map, "onClick", runIdentifies); } function runIdentifies(evt) { var defTask1 = new dojo.Deferred(), defTask2 = new dojo.Deferred; var dlTasks = new dojo.DeferredList([defTask1, defTask2]); dlTasks.then(showResults); //defTasks will fire after defTask1 and defTask2 have completed //These parameters change with each request idParams.width = map.width; idParams.height = map.height; idParams.geometry = evt.mapPoint; idParams.mapExtent = map.extent; try { idTask1.execute(idParams, defTask1.callback, defTask1.errback); //Pass the response into the callback on defTask1 } catch (e) { console.log("Error caught"); console.log(e); defTask1.errback(e); //If you get an error, execute the errback } try { idTask2.execute(idParams, defTask2.callback, defTask2.errback); //Pass the response into the callback on defTask2 } catch (e) { console.log("Error caught"); console.log(e); defTask2.errback(e); //If you get an error, execute the errback } } function showResults(r) { //The format of 'r' is [[Boolean task 1 success, [task 1 results]],[Boolean task 2 success, [task 2 results]]] //using the array 'r', build and show your infoWindow as normal } I created an alert with the value 'r' for each event triggered, and the alert window worked. I just need the code to build the pop up window populated by the array.
أكثر...