Select to view content in your preferred language

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

1770
1
07-11-2016 04:29 PM
ChristopherLai
Deactivated User

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

           });

0 Kudos
1 Reply
ChrisSmith7
Honored Contributor

Christopher,

It looks like this is part of a school assignment. I would recommend you check out this:

Using QueryTask, Query, and FeatureSet | Guide | ArcGIS API for JavaScript 3.17

Specifically, I'd have a look at the "Create a function to show the results" section to see if that gives you any ideas!

0 Kudos