Hi
I'm wondering if someone could help with this query. I am running a queryTask on a service which returns a postcode polygon on a map. I want to give the user the option to select from multiple results so that in case it returns more than one postcode result the user can then select the correct postcode from a dropdown. My current code is as follows:
function execute() { // var queryTask = new QueryTask("http://mapservice1"); var query = new Query(); query.returnGeometry = true; query.outFields = [ "POSTCODE" ]; query.text = dom.byId("Postcode").value.toUpperCase(); queryTask.execute(query, showResults); }; function showResults(results) { var resultItems = []; var inBuffer = []; var resultCount = results.features.length; for (var i = 0; i < resultCount; i++) { inBuffer.push(results.features.geometry); var featureAttributes = results.features.attributes; var graphic = results.features; graphic.setSymbol(symbol); map.graphics.add(graphic); var strNum = 100; var newExtent = graphic.geometry.getExtent(); newExtent.xmin = newExtent.xmin - strNum; newExtent.ymin = newExtent.ymin - strNum; newExtent.xmax = newExtent.xmax + strNum; newExtent.ymax = newExtent.ymax + strNum; map.setExtent(newExtent); for (var attr in featureAttributes) { resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>"); } resultItems.push("<br>"); } var query2 = new Query(); query2.geometry = geometryEngine.union(inBuffer); query2.returnGeometry = false; query2.outFields = ["NAME", "OBJECTID"]; var queryTask2 = new QueryTask("http://e/SEARCH/MapServer/15");
Should I add an extra function before 'showResults' in the case that the queryTask returns multiple postcode results? Any help would be appreciated.