Can I query by polygons using different map services? I'm trying a query to list all of the features inside a county. The query is executing, but I'm not getting any results.
Here's my code: ______________
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=7" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> <title>QueryTask with query geometry from another task</title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.2/js/dojo/dijit/themes/claro/claro.css"> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.2"></script>
var map; /*Initialize map, buffer, & query params*/ function init() { var startExtent = new esri.geometry.Extent({"xmin":3336800.8350631,"ymin":2636200.25720764,"xmax":6477996.0793392,"ymax":5025218.13686783,"spatialReference":{"wkid":3089}}); var map = new esri.Map("mapDiv", {extent:startExtent}); //listen for when map is loaded and then add query functionality dojo.connect(map, "onLoad", initFunctionality); //after map loads, connect to listen to mouse move & drag events dojo.connect(map, "onMouseMove", showCoordinates); var streetMap = new esri.layers.ArcGISDynamicMapServiceLayer("http://dingo.gapanalysisprogram.com/ArcGIS/rest/services/PADUS/PADUS_status/MapServer"); map.addLayer(streetMap); var gap = new esri.layers.ArcGISDynamicMapServiceLayer("http://dingo.gapanalysisprogram.com/ArcGIS/rest/services/PADUS/Ancillary/MapServer"); map.addLayer(gap); }
//identify proxy page to use if the toJson payload to the geometry service is greater than 2000 characters. //If this null or not available the buffer operation will not work. Otherwise it will do a http post to the proxy. //esriConfig.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx"; esriConfig.defaults.io.proxyUrl = "http://dingo.gapanalysisprogram.com/proxy/proxy.ashx";
esriConfig.defaults.io.alwaysUseProxy = false;
// Query var query = new esri.tasks.Query(); query.returnGeometry = true; //query.outFields = ["P_Des_Nm","P_Loc_Nm","Own_Name","Mang_Name"]; query.outFields = ["FID"]; query.outSpatialReference = {"wkid":3089}; var infoTempContent = "FID = ${FID}"+ "Remove Selected Features"; //Create InfoTemplate for styling the result infowindow. var infoTemplate = new esri.InfoTemplate("County: ${FID}", infoTempContent); map.infoWindow.resize(275,190);
var firstGraphic = null; // +++++Listen for QueryTask onComplete event+++++ dojo.connect(queryTask, "onComplete", function(graphics) { firstGraphic = graphics.features[0]; var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new dojo.Color([100,100,100]), 3), new dojo.Color([255,0,0,0.20])); firstGraphic.setSymbol(symbol); firstGraphic.setInfoTemplate(infoTemplate);
// +++++Listen for QueryTask executecomplete event+++++ dojo.connect(queryTaskTouches, "onComplete", function(fset) { var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new dojo.Color([100,100,100]), 2), new dojo.Color([0,0,255,0.20]));
function showCoordinates(evt) { //get mapPoint from event var mp = evt.mapPoint; //display mouse coordinates dojo.byId("info").innerHTML = mp.x + ", " + mp.y; }
dojo.addOnLoad(init); </script> </head>
<body class="claro"> Click on map to select census block group that intersects the map click and all block groups that touch selected group. <div id="mapDiv" style="width: 850px; height:500px; position:relative;"> <span id="info" style="position:absolute; right:25px; bottom:5px; color:#000; z-index:50;"></span> </div> <span id="messages"></span> </body> </html>