//build query task myQueryTask = new esri.tasks.QueryTask("http://thgistest01/ArcGIS/rest/services/PollingDistrict/MapServer/1"); //Can listen for onComplete event to process results or can use the callback option in the queryTask.execute method. //dojo.connect(queryTask, "onComplete", showResults); //build query filter myQuery = new esri.tasks.Query(); new esri.geometry.Point ([x,y], new esri.SpatialReference({ wkid: sr })); mQuery.returnGeometry = "true"; myQuery.outFields = ["Polling_Station_UPRN", "District_Code"]; myQueryTask.execute(myQuery,showResults);
Solved! Go to Solution.
new esri.geometry.Point (535487,182880, new esri.SpatialReference({ wkid: 2770 }));
Build an esri.geometry.Point() from your query string parameters and set that as query.geometry. And you probably don't need returnGeometry = true if you're not using a map.
query = new esri.tasks.Query(); var XY = new esri.geometry.Point (535487,182880, new esri.SpatialReference({ wkid: 2770 })); query.geometry = XY; query.outFields = ["Polling_Station_UPRN", "District_Code"]; queryTask.execute(query,showResults);
new esri.geometry.Point (535487,182880, new esri.SpatialReference({ wkid: 2770 }));
<script type="text/javascript">$.loadSite('http://cms.esriuk.com/TowerHamlets/', 'ab066578-6325-495c-ac12-da7a9696ac02', '#mygaz', configLoaded); dojo.require("esri.tasks.query"); dojo.require("esri.tasks.geometry"); dojo.require("dojo.parser"); dojo.require("esri.map"); var queryTask; var uprn; function configLoaded(config /* site config */) { config = config; $("#lhDiv").bind({ "locatorhub.pickList": function (evt, locatorhub, picklist) { // added to fix bug in release 6 (SP5) of LVF. Will be fixed in release 7 $(".jquery-locatorhub-picklistrow").removeAttr("href"); $(".jquery-locatorhub-results").css("display", "block"); }, "locatorhub.searchDialogLocationFound": function (evt, locatorhub, match) { // Insert what you want to do with an address match here!!!! AddressFound(match) }, "locatorhub.matchedLocationClick": function (evt, locatorhub, match) { // Insert what you want to do with an address match here!!!! AddressFound(match); }, "locatorhub.addressSearchError": function () { alert("Address Search error"); }, "locatorhub.error": function (evt, error) { alert("locator hub error") } }) } function AddressFound(match) { x = match.Point.x; y = match.Point.y; sr = match.Point.spatialReference.wkid; ; queryTask = new esri.tasks.QueryTask("http://thgistest01/ArcGIS/rest/services/PollingDistrict/MapServer/1"); //Can listen for onComplete event to process results or can use the callback option in the queryTask.execute method. //dojo.connect(queryTask, "onComplete", showResults); //build query filter query = new esri.tasks.Query(); var XY = new esri.geometry.Point (x,y, new esri.SpatialReference({ wkid: 27700 })); query.geometry = XY; query.outFields = ["Polling_Station_UPRN"]; //query.text = "Bow East 2"; queryTask.execute(query); dojo.connect(queryTask, "onComplete", function (myFeatureSet) { var s = ""; for (var i=0, il=myFeatureSet.features.length; i<il; i++) { var featureAttributes = myFeatureSet.features.attributes; for (att in featureAttributes) { s = s + "<strong>" + att + ": </strong>" + featureAttributes[att] + "<br />"; } } dojo.byId("info").innerHTML = s; uprn = featureAttributes[att]; } ); alert (uprn) }