unable to get feature when i select a value in second drop box

545
3
12-19-2019 05:04 AM
SatyanarayanaNarmala
New Contributor III

Hi all,

i have 2 layers, zone and circle. when i filter (filter.png)  zone select a name it will zoom to that particular zone and print on console as 1. And when i select zone and circle combination only 0 zero records is fetched as seen in console (s.png).

$(document).on("change", "#Zone_list", function () {
                if ($("#Zone_list").val() == "All Zones") {
                    $("#Circle_list").empty();
                    $("#table_title").text("All Zones");
                    map.addLayer(district_layer);
                    map.removeLayer(mandal_layer);
                    map.setExtent(district_layer.fullExtent);
                    basicOnLoadFun();
                } else {
                    $("#table_title").text("Zone: " + $("#Zone_list :selected").text());
                    setMapFeatureToExtent(QueryTask, Query, district_url, 'sde.sde.ghmc_zones_pt1.zoneid = ' + $("#Zone_list").val());
                    var query_con = 'sde.sde.GHMC_Circles_pt1.zone_id = ' + $("#Zone_list").val();
                   
                    selectedDistrict(query_con);
                }
            });

            $(document).on("change", "#Circle_list", function () {
                if ($("#Circle_list").val() == "All Circles") {
                    setMapFeatureToExtent(QueryTask, Query, district_url, 'sde.sde.ghmc_zones_pt1.zoneid = ' + $("#Zone_list").val());
                } else {
                    var condition = 'sde.sde.GHMC_Circles_pt1.circle = ' + $("#Circle_list").val() + ' AND sde.sde.GHMC_Circles_pt1.zone_id = ' + $("#Zone_list").val();
                
                    setMapFeatureToExtent(QueryTask, Query, mandal_url, condition);
                    
                }
            });

            function selectedDistrict(query_con) {
                map.removeLayer(district_layer);
                mandal_layer.setDefinitionExpression(query_con);
                map.addLayer(mandal_layer);
                field_key = "sde.sde.circlepara." + $('input[name=Indecator]:checked').val();
                var out_fields = "sde.sde.GHMC_Circles_pt1.zone || sde.sde.GHMC_Circles_pt1.zone_id || sde.sde.GHMC_Circles_pt1.cir_name || sde.sde.GHMC_Circles_pt1.circle ||
                getAttributes(Query, QueryTask, query_con, mandal_url, "sde.sde.GHMC_Circles_pt1.cir_name||sde.sde.GHMC_Circles_pt1.circle", "#Circle_list", "Circles");
              
             
                createTable(QueryTask, Query, mandal_url, query_con, out_fields);
            };

            function setMapFeatureToExtent(QueryTask, Query, url, condition) {
                var queryTask = new QueryTask(url);
                var query = new Query();
                query.returnGeometry = true;
                query.outFields = ["*"];
                query.outSpatialReference = map.spatialReference;
                query.where = condition;
                
                queryTask.execute(query, function (results) {
                    console.log(results.features.length)
                    map.setExtent(results.features[0].geometry.getExtent())
                });
            };

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Satyanarayana,

Is the zone_id and circle numeric fields or a strings?

0 Kudos
SatyanarayanaNarmala
New Contributor III

Robert,

Thanks for the reply. Both are integers. the same query is working in arcmap, but not on gisservice.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Have you tried to just execute the query on the rest endpoint page?

sde.sde.GHMC_Circles_pt1.circle = 1 AND sde.sde.GHMC_Circles_pt1.zone_id = 1

0 Kudos