Select to view content in your preferred language

query data from a web service

5355
17
Jump to solution
04-23-2015 02:56 AM
sundussabbah
Deactivated User

Hello everybody, I'm trying to query some data from a service table I wrote:       var query = new Query();       query.outFields = [ " * " ];           query.returnGeometry = true;               var queryTask = new QueryTask("url");       queryTask.execute(query,showResults);       but the showResult is never executed , what is the reason ?? please help me

0 Kudos
17 Replies
sundussabbah
Deactivated User

Ok, thank you, I understand now

0 Kudos
KushendraShah1
Emerging Contributor

Tom, is there way you can make spatial query on feature layer that return geometry spatially without returning attributes? Thanks

0 Kudos
TomSellsted
MVP Regular Contributor

Kushendra,

Yes!  You specify an empty array for outFields and specify the query geometry.  Something like:

query.geometry = webMercatorUtils.webMercatorToGeographic(firstGraphic.geometry)

query.spatialRelationship = Query.SPATIAL_REL_TOUCHES;

query.outFields = [];

queryTask.execute(query);

Regards,

Tom

KushendraShah1
Emerging Contributor

Thanks Tom

0 Kudos
TomSellsted
MVP Regular Contributor

You are welcome Kushendra!

0 Kudos
SatyanarayanaNarmala
Occasional Contributor

hi sundus

where am i going wrong here. kindly guide me

<!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>Popup</title>

    <link rel="stylesheet" href="http://js.arcgis.com/3.13/dijit/themes/claro/claro.css">

    <link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css">

    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css">

    <style>

      html, body, #map {

        padding: 0;

        margin: 0;

        height: 100%;

      }

      /* Change color of icons to match bar chart and selection symbol */

      .esriPopup.dark div.titleButton,

      .esriPopup.dark div.titlePane .title,

      .esriPopup.dark div.actionsPane .action {

        color: #A4CE67;

      }

      /* Additional customizations */

      .esriPopup.dark .esriPopupWrapper {

        border: none;

      }

      .esriPopup .contentPane {

        text-align: left;

      }

      .esriViewPopup .gallery {

        margin: 0 auto;

      }

    </style>

    <script src="http://js.arcgis.com/3.13/"></script>

    <script>

      var map;

      require([

        "esri/map",

        "esri/dijit/Popup", "esri/dijit/PopupTemplate",

        "esri/layers/FeatureLayer",

        "esri/dijit/Search",

        "esri/tasks/QueryTask",

        "esri/tasks/query",

        "esri/symbols/SimpleFillSymbol", "esri/Color",

        "dojo/dom-class", "dojo/dom-construct", "dojo/on",

        "dojox/charting/Chart", "dojox/charting/themes/Dollar",

        "dojo/domReady!"

      ], function(

        Map,

        Popup, PopupTemplate,

        FeatureLayer, Search,

        QueryTask, Query,

        SimpleFillSymbol, Color,

        domClass, domConstruct, on,

        Chart, theme

      ) {

        //The popup is the default info window so you only need to create the popup and

        //assign it to the map if you want to change default properties. Here we are

        //noting that the specified title content should display in the header bar

        //and providing our own selection symbol for polygons.

        var fill = new SimpleFillSymbol("solid", null, new Color("#A4CE67"));

        var popup = new Popup({

            fillSymbol: fill,

            titleInBody: false

        }, domConstruct.create("div"));

        //Add the dark theme which is customized further in the <style> tag at the top of this page

        domClass.add(popup.domNode, "lighter");

        map = new Map("map", {

          basemap: "satellite",

          center: [79.2, 18.10],

          zoom: 8,

          infoWindow: popup

        });

       

        var template = new PopupTemplate({

          title: "TELANGANA PATTA APPLICANTS",

          description: "Application No: {application_no} <br> <br>DISTRICT: {district_name1} <br><br>MANDAL: {mandal_name1}<br><br> VILLAGE: {village_name1} <br><br>  OCCUPANT NAME: {name_of_the_occupant} <br><br>ADDRESS: {present_address} <br><br> Survey No.: {survey_no} <br><br> LAND EXTENT: {extent_of_land} <br>",

        

       

        });

        var featureLayer = new FeatureLayer("http://gisserver.cgg.gov.in/arcgis/rest/services/sample/patta1/FeatureServer/0",{

          mode: FeatureLayer.MODE_ONDEMAND,

          outFields: ["*"],

          infoTemplate: template

        });

        map.addLayer(featureLayer);

       

        var featureLayer2 = new FeatureLayer("http://gisserver.cgg.gov.in/arcgis/rest/services/sample/patta1/FeatureServer/2",{

          mode: FeatureLayer.MODE_ONDEMAND,

          outFields: ["*"]

         

         

        });

        map.addLayer(featureLayer2);

       

        var featureLayer1 = new FeatureLayer("http://gisserver.cgg.gov.in/arcgis/rest/services/sample/patta1/FeatureServer/1",{

          mode: FeatureLayer.MODE_ONDEMAND,

          outFields: ["*"]

         

        });

        map.addLayer(featureLayer1);

       

       

       

       

      });

     

     

 

 

   

   

   

    queryTask = new QueryTask("http://gisserver.cgg.gov.in/arcgis/rest/services/sample/patta1/FeatureServer/2");

   

    query = new Query();

    query.returnGeometry = true;

    query.outFields = ["*"];

   

   

        function executeQueryTask(population) {

  //set query based on what user typed in for population;

alert(population);

  query.where = "mname = '" + population + "'";

  //execute query

  queryTask.execute(query);

}

function showResults(featureSet) {

  //remove all graphics on the maps graphics layer

  map.graphics.clear();

  //Performance enhancer - assign featureSet array to a single variable.

  var resultFeatures = featureSet.features;

  //Loop through each feature returned

  for (var i=0, il=resultFeatures.length; i<il; i++) {

    //Get the current feature from the featureSet.

    //Feature is a graphic

    var graphic = resultFeatures;

    graphic.setSymbol(symbol);

    //Set the infoTemplate.

    graphic.setInfoTemplate(infoTemplate);

    //Add graphic to the map graphics layer.

    map.graphics.add(graphic);

  }

}

    </script>

  </head>

 

  <body class="claro">

 

  

  <form name="classic">

<select name="countries" size="4" onChange="updatecities(this.selectedIndex)" style="width: 150px">

<option selected>Select A DISTRICT</option>

<option value="1">ADILABAD</option>

<option value="2">KARIMNAGAR</option>

<option value="3">KHAMMAM</option>

<option value="4">MAHABUBNAGAR</option>

<option value="5">MEDAK</option>

<option value="6">NALGONDA</option>

<option value="7">NIZAMABAD</option>

<option value="8">RANGA REDDY</option>

<option value="9">WARANGAL</option>

<option value="10">HYDERABAD</option>

</select>

Mandals:

<select name="cities" size="4" style="width: 150px" onClick="executeQueryTask(this.options[this.options.selectedIndex].value);">  <!-- alert(this.options[this.options.selectedIndex].value) -->

</select>

</form>

<script type="text/javascript">

var countrieslist=document.classic.countries

var citieslist=document.classic.cities

var cities=new Array()

cities[0]=""

cities[1]=["ADILABAD ", "    ASIFABAD ", "    BAZARHATHNOOR ", "    BEJJUR ", "    BELA ", "    BELLAMPALLE ", "    BHAINSA ", "    BHEEMINI  ", " BOATH ", "    CHENNUR ", "    DAHEGAON ", "    DANDEPALLE ", "    DILAWARPUR ", "    GUDIHATHNUR ", "    ICHODA ", "    INDERAVELLY ", "    JAINAD ", "    JAINOOR ", "    JAIPUR ", "    JANNARAM ", "    KADDAMPEDDUR ", "    KAGAZ NAGAR ", "    KASIPET ", "    KERAMERI ", "    KHANPUR     ", "    KOTAPALLE ", "    KOUTHALA ", "    KUBEER ", "    KUNTALA ", "    LAXMANCHANDA    ", "    LOHESRA ", "    LUXETTIPET     ", "    MAMDA     ", "    MANCHERIAL ", "        MANDAMARRI ", "        MUDHOLE     ", "    NARNOOR ", "    NENNAL ", "    NERADIGONDA ", "    NIRMAL ", "    REBBANA ", "    SARANGAPUR ", "    SIRPUR (T) ", "    SIRPUR (U) ", "    TALAMADUGU ", "    TAMSI     ", "    TANDUR ", "    TANUR ", " TIRYANI  ", "    UTNUR     ", "    VEMANPALLE     ", "    WANKDI"]

cities[2]=["BEJJANKI", "BHEEMADEVARPALLE", "BOINPALLE", "CHANDURTHI", "CHIGURUMAMIDI", "CHOPPADANDI", "DHARMAPURI", "DHARMARAM", "ELKATHURTHI", "ELLANTHAKUNTA", "GAMBHIRAOPET", "GANGADHARA", "GOLLAPALLE", "HUSNABAD", "HUZURABAD", "IBRAHIMPATNAM", "JAGTIAL", "JAMMIKUNTA", "JULAPALLE", "KAMALAPUR", "KAMANPUR", "KARIMNAGAR", "KATARAM", "KATHLAPUR", "KESAVAPATNAM", "KODIMIAL", "KOHEDA", "KONARAOPETA", "KORATLA", "MAHADEVPUR", "MALHARRAO", "MALLAPUR", "MALLIAL", "MANAKONDUR", "MANTHANI", "MEDIPALLE", "METPALLE", "MUSTABAD", "MUTHARAM MAHADEVPUR", "MUTHARAM MANTHANI", "ODELA", "PEDDAPALLE", "PEGADAPALLE", "RAIKAL", "RAMADUGU", "RAMAGUNDAM", "SAIDAPUR", "SARANGAPUR", "SIRSILLA", "SRIRAMPUR", "SULTANABAD", "THIMMAPUR", "VEENAVANKA", "VELGATOOR", "VEMULAWADA", "YELLA REDDI PETA"]

cities[3]=["ASWAPURAM", "ASWARAOPETA", "BAYYARAM", "BHADRACHALAM", "BONAKAL", "BURGAMPADU", "CHANDRUGONDA", "CHERLA", "CHINTHAKANI", "DAMMAPETA", "DUMMUGUDEM", "ENKURU", "GARLA", "GUNDALA", "JULURPAD", "KALLURU", "KAMEPALLE", "KHAMMAM RURAL", "KHAMMAM URBAN", "KONIJERLA", "KOTHAGUDEM", "KUSUMANCHI", "MADHIRA", "MANUGURU", "MUDIGONDA", "MULAKALAPALLE", "NELAKONDAPALLE", "PALAWANCHA", "PENUBALLI", "PINAPAKA", "SATHUPALLE", "SINGARENI", "TEKULAPALLE", "THALLADA", "THIRUMALAYAPALEM", "VEMSOOR", "VENKATAPURAM", "WAZEED", "WYRA", "YELLANDU", "YERRUPALEM"]

cities[4]=["ACHAMPETA", "ADDAKAL", "AIZA", "ALAMPUR", "AMANGAL", "AMRABAD", "ATMAKUR", "BALANAGAR", "BALMOOR", "BHOOTHPUR", "BIJINAPALLE", "BOMRASPETA", "CHINNA CHINTA KUNTA", "DAMARAGIDDA", "DEVARKADARA", "DHANWADA", "DHARUR", "DOULATABAD", "FAROOQNAGAR", "GADWAL", "GHANPUR", "GHATTU", "GOPALPETA", "HANWADA", "ITIKYAL", "JADCHERLA", "KALAWAKURTHY", "KESHAMPETA", "KODAIR", "KOILKONDA", "KOLLAPUR", "KONDANGAL", "KONDURG", "KOSGI", "KOTHAKONTA", "KOTHUR", "LINGAL", "MADDUR", "MADGUL", "MAGANOOR", "MAHABUBNAGAR", "MAKTHAL", "MALADAKAL", "MANOPADU", "MIDJIL", "NAGAR KURNOOL", "NARAYANPET", "NARVA", "NAWABPET", "PANGAL", "PEBBAIR", "PEDDAKOTHAPALLE", "PEDDAMANDADI", "TADOOR", "TALAKONDAPALLE", "TELKAPALLE", "THIMMAJIPETA", "UPPUNUNTHALA", "UTKOOR", "VANGOOR", "VEEPANGANDLA", "VELDANDA", "WADDEPALLE", "WANAPARTHY"]

cities[5]=["ALLADURG", "ANDOLE", "CHEGUNTA", "CHINNAKODUR", "DOULTHABAD", "DUBBAK", "GAJWEL", "HATHNOORA", "JAGDEVPUR", "JHARASANGAM", "JINNARAM", "KALHER", "KANGTI", "KOHIR", "KONDAPAK", "KONDAPUR", "KOWDIPALLI", "KULCHARAM", "MANOOR", "MEDAK", "MIRDODDI", "MULUGU", "MUNIPALLE", "NANGNUR", "NARAYANKHED", "NARSAPUR", "NYALKAL", "PAPANNAPET", "PATANCHERU", "PULKAL", "RAIKODE", "RAMACHANDRAPURAM", "RAMAYAMPET", "REGODE", "SADASIVPET", "SANGAREDDY", "SHANKARAMPET(A)", "SHANKARAMPET(R)", "SHIVAMPET", "SIDDIPET", "TEKMAL", "TOOPRAN", "WARGAL", "YELDURTHI", "ZAHIRABAD"]

cities[6]=["ALAIR", "ANUMULA", "ATMAKUR  (S)", "ATMAKUR (M)", "BHUVANAGIRI", "BIBINAGAR", "BOMMALARAMARAM", "CHANDAM PET", "CHANDUR", "CHILKUR", "CHINTHA PALLE", "CHITYALA", "CHIVVEMLA", "CHOUTUPPAL", "DAMERACHERLA", "DEVARAKONDA", "GARIDE PALLE", "GUNDALA", "GUNDLA PALLE", "GURRAMPODE", "HUZURNAGAR", "JAJI REDDI GUDEM", "KANGAL", "KATTANGOOR", "KETHEPALLE", "KODAD", "M TURKAPALLE", "MARRI GUDA", "MATTAMPALLE", "MELLACHERVU", "MIRYALAGUDA", "MOTHEY", "MOTHKUR", "MUNAGALA", "MUNUGODE", "NADIGUDEM", "NAKREKAL", "NALGONDA", "NAMPALLE", "NARAYANAPUR", "NARKETPALLE", "NERED CHERLA", "NIDAMANUR", "NUTHANKAL", "PEDDA ADISERLAPALLE", "PEDDAVURA", "PENPAHAD", "POCHAMPALLE", "RAJAPET", "RAMANNAPETA", "SALIGOURARAM", "SURYAPET", "THIPPARTHI", "THIRUMALAGIRI", "THRIPURARAM", "THUNGA THURTHI", "VALIGONDA", "VEMULAPALLE", "YADAGIRIGUTTA"]

cities[7]=["ARMUR", "BALKONDA", "BANSWADA", "BHEEMGAL", "BHIKNUR", "BICHKUNDA", "BIRKOOR", "BODHAN", "DHARPALLE", "DICH PALLE", "DOMAKONDA", "GANDHARI", "JAKRANPALLE", "JUKKAL", "KAMAREDDY", "KAMMAR PALLE", "KOTGIRI", "LINGAMPET", "MACHAREDDY", "MADNUR", "MAKLOOR", "MORTAD", "NAGA REDDIPET", "NANDIPET", "NAVIPET", "NIZAM SAGAR", "NIZAMABAD", "NIZAMABAD (M)", "PITLAM", "RANJAL", "SADASIVANAGAR", "SIRKONDA", "TADWAI", "VARNI", "VELPUR", "YEDA PALLE", "YELLAREDDY"]

cities[8]=["BALANAGAR", "BANTARAM", "BASHEERABAD", "CHEVELLA", "DHARUR", "DOMA", "GANDEED", "GHATKESAR", "HAYATHNAGAR", "IBRAHIMPATAM", "IBRAHIMPATNAM", "KANDUKUR", "KEESARA", "KULKACHARLA", "MAHESWARAM", "MALKAJGIRI", "MANCHAL", "MARPALLE", "MEDCHAL", "MOINABAD", "MOMINPET", "NAWABPET", "PARGI", "PEDDEMUL", "PUDUR", "QUTHBULLAPUR", "RAJENDRANAGAR", "SAROORNAGAR", "SERLINGAMPALLY", "SHABAD", "SHAMIRPET", "SHAMSHABAD", "SHANKARPALLE", "TANDUR", "UPPAL", "VIKARABAD", "YACHARAM", "YELAL"]

cities[9]=["ATMAKUR", "BACHANNAPETA", "BHUPALPALLE", "CHENNARAOPET", "CHERIYAL", "CHITYAL", "DEVARUPPULA", "DHARMASAGAR", "DORNAKAL", "DUGGONDI", "ETURNAGARAM", "GEESUGONDA", "GHANAPUR", "GHANPUR(stn)", "GOVINDARAOPET", "GUDUR", "HANAMKONDA", "HASANPARTHY", "JANGAON", "KESAMUDRAM", "KHANAPUR", "KODAKANDLA", "KOTHAGUDEM", "KURAVI", "LINGALA GHANPUR", "MADDUR", "MAHABUBABAD", "MANGAPET", "MARIPEDA", "MOGULLAPALLE", "MULUG", "NALLABELLY", "NARMETTA", "NARSAMPET", "NARSIMHULAPET", "NEKKONDA", "NELLIKUDUR", "PALAKURTHI", "PARKAL", "PARVATHAGIRI", "RAGHUNATHA PALLE", "RAIPARTHY", "REGONDA", "SANGEM", "TADVAI", "THORRUR", "VENKATAPUR", "WARANGAL", "WARDHANNAPET", "ZAFFERGADH"]

cities[10]=["HYDERABAD"]

function updatecities(selectedcitygroup){

    citieslist.options.length=0

    if (selectedcitygroup>0){

        for (i=0; i<cities[selectedcitygroup].length; i++)

            citieslist.options[citieslist.options.length]=new Option(cities[selectedcitygroup].split("|")[0], cities[selectedcitygroup].split("|")[1])

    }

}

</script>

 

    <div id="map"></div>

   

  </body>

</html>

0 Kudos
TomSellsted
MVP Regular Contributor

Satyanarayana,

Can you be more specific about the problem you are having with your script?  What is it not doing?

Regards,

Tom

0 Kudos
sundussabbah
Deactivated User

what is the problem with the code??

I will help if I can

0 Kudos