AnsweredAssumed Answered

How Do I Draw Queried Geometry w/ ArcGIS JavaScript API?

Question asked by chrislai902 on Jul 11, 2016
Latest reply on Jul 11, 2016 by csgeosol1

I am new to all of coding and I have a rest point with all of my park polygons, what I want to do is be able to  select a park  name from a drop down menu and query out and display the single park that is chosen. I believe I have everything set up to query my geometry, now I don't know how to get it to draw the queried feature. right now I have 2 different drop downs. According to my professor i have the 2 selections stored in "selectedParkFeature" and "selectedLayer" variable, and all I have to do now is to draw them on the map. I have researched and I am stuck, please help. I am doing all of this on ArcGIS JavaScript API 3.17.

 

 

        query("#selectParkName").on('change', function (evt) {

        var tempParkName = evt.target.value;

        getParkFeature(tempParkName);

    });

 

 

 

 

    //function to select the park

    function getParkFeature(in_park_name) {

        var query = new Query();

        query.where = "NAME='" + in_park_name + "'";

        query.outFields = ["*"];         

        park.queryFeatures(query, function (featureSet) {

            console.log(featureSet);

            selectedParkFeature = featureSet.features[0]; 

        });

    }

 

 

 

 

       query("#myPick").on('change', function (evt) {            

           var tempLayerName = evt.target.value;

           chooseLayer(tempLayerName);

       });

 

 

 

 

       function chooseLayer(inLyrName) {

           selectedLayer = map.getLayer(inLyrName); 

           var query = new Query();

           query.geometry = selectedParkFeature.geometry;

           query.outFields = ["*"];

           selectedLayer.queryFeatures(query, function (featureSet) {

               console.log(featureSet);

               //now you can draw these features on the map

 

 

 

 

           });

Outcomes