AnsweredAssumed Answered

Query & QueryTask with a feature layer not shown until Query Task executed

Question asked by mrogers83 on Mar 6, 2014
Latest reply on Mar 10, 2014 by mrogers83
I am trying to query a feature layer that is not shown on the map until the query is actually executed. I have a button that I am using to set off the query when it is clicked. Here is the code that I am trying to use:
on(dom.byId("mapshow"), "click", selectHistorical); function selectHistorical(){  var queryTask = new QueryTask(window.historicalUrl);  var query = new Query();  query.returnGeometry=true;  query.outFields=window.historicalOutFields;  query.text = dom.byId("mydropdown").value;  query.outSpatialReference = {"wkid":2236};  dojo.connect(queryTask, "onComplete", function(featureSet){   map.graphics.clear();   dojo.forEach(featureSet.features, function(feature){    var graphic = feature;    map.graphics.add(graphic);   });  });  queryTask.execute(query); }


The feature layer is already included in the webpage in on demand mode. What I am trying to do is query the layer so that the only items that show up from that layer are the items from one specific unit id. This is to show the history of one specific vehicle over time.  Eventually we would also want to query the time so that the user can specify a certain time and date to get the historical information for one specific vehicle.  I am posting a photo of the viewer.

[ATTACH=CONFIG]31992[/ATTACH]

The dropdown menu in the right panel has the unit id's for all police vehicles. What I want is for the historical data (in the historical feature layer) to be shown for whatever specific unit id is selected when I click on the show on map button.

I am fairly new to coding with esri, so any help is appreciated.

Attachments

Outcomes