I am trying to popup an InfoWindow when user click on visible layer after selecting Identify Tool from the menu as shown in the attached image.
I followed this example URL(Display identify results in popup | ArcGIS API for JavaScript ) from ESRI officail website and coded so far as below but not succeeded yet. It is showing "map.infoWindow.setFeatures" is not a function" error.
Please help me to solve this problem. Please find the code in the attachment.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Identify with Popup</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css">
<style>
html, body, #map {height:100%;width:100%;margin:0;padding:0;}
</style>
<script src="http://js.arcgis.com/3.14/"></script>
<script>
var map;
var identifyListener;
require([
"esri/map",
"esri/layers/FeatureLayer",
"esri/dijit/InfoWindow",
"esri/InfoTemplate",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/tasks/IdentifyTask",
"esri/tasks/IdentifyParameters",
"dojox/layout/FloatingPane",
"esri/dijit/Popup",
"dojo/_base/array",
"esri/Color",
"dojo/dom-construct",
"dojo/dom",
"dojo/on",
"dojo/domReady!"
], function (
Map, FeatureLayer, InfoWindow, InfoTemplate, ArcGISDynamicMapServiceLayer, SimpleFillSymbol,
SimpleLineSymbol, IdentifyTask, IdentifyParameters, FloatingPane, Popup,
arrayUtils, Color, domConstruct, dom, on
) {
var identifyTask, identifyParams;
var infoWindow = new InfoWindow({}, domConstruct.create("div"));
infoWindow.startup();
var popup = new Popup({
fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25]))
}, domConstruct.create("div"));
map = new Map("map", {
basemap: "satellite",
center: [84.0000, 20.1500],
zoom: 7,
infoWindow: infoWindow
});
map.on("load", mapReady);
var stateLayerURL = "http://10.172.10.152/odisha/rest/services/GisMain/FYEARPERMITS/MapServer/";
map.addLayer(new ArcGISDynamicMapServiceLayer(stateLayerURL,
{ opacity: 0.55 }));
function mapReady () {
//map.on("click", executeIdentifyTask);
on(dom.byId("identifyMe"), "click", function(evt){
identifyListener = dojo.connect(map, "onClick", executeIdentifyTask);
});
//create identify tasks and setup parameters
identifyTask = new IdentifyTask(stateLayerURL);
identifyParams = new IdentifyParameters();
identifyParams.tolerance = 3;
identifyParams.returnGeometry = true;
identifyParams.layerIds = [6];
identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_TOP;
identifyParams.width = map.width;
identifyParams.height = map.height;
}
function executeIdentifyTask (event) {
identifyParams.geometry = event.mapPoint;
identifyParams.mapExtent = map.extent;
var deferred = identifyTask
.execute(identifyParams)
.addCallback(function (response) {
// response is an array of identify result objects
// Let's return an array of features.
return arrayUtils.map(response, function (result) {
var feature = result.feature;
var layerName = result.layerName;
feature.attributes.layerName = layerName;
var taxParcelTemplate = new InfoTemplate("${S_NAME}", "Tractors : ${TRACTORS_2012}");
feature.setInfoTemplate(taxParcelTemplate);
return feature;
});
});
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(event.mapPoint);
}
});
</script>
</head>
<body>
<button id="identifyMe">Identify</button>
<div id="map">
</div>
</body>
</html>