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 selection stored in "selectedParkFeature" variable, and all I have to do now is to draw it on the map. I have researched and I am stuck. I am doing all of this on ArcGIS API for JavaScript 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];
});
}
1 Answer 1
Modify your function:
//function to select the park
function getParkFeature(in_park_name) {
var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
new Color([255,0,0]), 2),new Color([255,255,0,0.25])
);
var query = new Query();
query.where = "NAME='" + in_park_name + "'";
query.outFields = ["*"];
park.queryFeatures(query, function (featureSet) {
console.log(featureSet);
selectedParkFeature = featureSet.features[0];
map.graphics.add(new Graphic(selectedParkFeature.geometry, sfs));
});
}
-
i changed it as is shown in your post, but it still will not draw. am I missing anything?Chris Lai– Chris Lai2016年07月13日 23:05:17 +00:00Commented Jul 13, 2016 at 23:05
Explore related questions
See similar questions with these tags.