1

I am getting all layers information on map using identifier.But i want if all layers is enable on map if i clicked on one layer i need only that information not all layers information using identifier in arcgis javascript api 3.17.here is the my code

function mapReady() {
 map.on("click", executeIdentifyTask);
 //create identify tasks and setup parameters
 identifyTask = new IdentifyTask("URL");
 identifyParams = new IdentifyParameters();
 identifyParams.tolerance = 3;
 identifyParams.returnGeometry = true;
 //identifyParams.layerIds = [35, 0, 5, 13, 8, 12, 14, 3, 15, 2, 7, 17, 18, 19, 1, 6, 9, 20, 21];
 //identifyParams.layerIds = [20, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13];
 //ask
 identifyParams.layerIds = [2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 19, 22, 23, 24, 26, 27, 28, 29, 30, 31, 33, 34, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 49, 50, 51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 63, 64, 65, 67, 68, 70, 71, 72];
 identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_VISIBLE;
 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;
 if (layerName == 'District') {
 //ask
 //console.log(feature.attributes.AssemblyCode);
 var taxParcelTemplate = new InfoTemplate("District Details", "DistrictCode:${DistrictCode}<br /> DistrictName:${DistrictName}");
 feature.setInfoTemplate(taxParcelTemplate);
 }
 else if (layerName == 'Taluk') {
 var taxParcelTemplate = new InfoTemplate("Taluk Details", "TalukCode:${TalukCode}<br /> TalukName:${TalukName}");
 feature.setInfoTemplate(taxParcelTemplate);
 // outFields: ["*"]
 }
 else if (layerName == 'Parliment') {
 var taxParcelTemplate = new InfoTemplate("Parlimentary Details", "ParliamentCode:${ParliamentCode}<br /> ParliamentName:${ParliamentName}");
 feature.setInfoTemplate(taxParcelTemplate);
 // outFields: ["*"]
 }
 else if (layerName == 'Assembly') {
 var taxParcelTemplate = new InfoTemplate("Assembly Details", "AssemblyCode:${AssemblyCode}<br /> AssemblyName:${AssemblyName}");
 feature.setInfoTemplate(taxParcelTemplate);
 // outFields: ["*"]
 }
 else if (layerName == 'Hobli') {
 var taxParcelTemplate = new InfoTemplate("Hobli Details", "HobliCode:${HobliCode}<br /> HobliName:${HobliName}");
 feature.setInfoTemplate(taxParcelTemplate);
 // outFields: ["*"]
 }
 //info details yet to add
 else if (layerName == 'Grampanchayat') {
 var taxParcelTemplate = new InfoTemplate("Grampanchayat Details", "GrampanchayatCode:${GrampanchayatCode}<br /> GrampanchayatName:${GrampanchayatName}");
 feature.setInfoTemplate(taxParcelTemplate);
 // outFields: ["*"]
 }
 else if (layerName == 'Village') {
 var taxParcelTemplate = new InfoTemplate("Village Details", "Code:${Code}<br /> Name:${Name}");
 feature.setInfoTemplate(taxParcelTemplate);
 // outFields: ["*"]
 }
 return feature;
 });
 });
 map.infoWindow.setFeatures([deferred]);
 map.infoWindow.show(event.mapPoint);
 }
asked Sep 20, 2016 at 8:58
1
  • can you explain more clearly? Commented Oct 12, 2016 at 11:15

1 Answer 1

1

firstly you change layerIds for only searching layer, if you search all layer delete this code;

identifyParams.layerIds = [2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 19, 22, 23, 24, 26, 27, 28, 29, 30, 31, 33, 34, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 49, 50, 51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 63, 64, 65, 67, 68, 70, 71, 72];

secondly change LAYER_OPTION_VISIBLE to LAYER_OPTION_TOP, so it only searching top layer in your layer list

identifyParams.layerOption = IdentifyParameters. LAYER_OPTION_TOP;
answered Oct 12, 2016 at 11:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.