Pulling my hair out over this -maybe can get some help here. I modified the "Query map with buffer polygon" service to use my own service. Have most of it working correctly (I can return features within buffer) except that when the code executes the queryTask - the features are returned in decimal degree and not in the KY State Plane (wkid: 3089) that I specified in the query outSpatialReference (which is also the same for the service I'm querying and the basemap). What's strange is that if I change the query to a non-spatial query (not using the buffer, but a simple where statement), the features return in the correct spatial reference. Any ideas on what I'm doing wrong here?
My server is 9.3.1 and using the Javascript API 2.1
The offending bits of the code are here - I commented out the where statement that works: // +++++Listen for GeometryService onBufferComplete event+++++ dojo.connect(gsvc, "onBufferComplete", function(geometries) { var symbol = new esri.symbol.SimpleFillSymbol("none", new esri.symbol.SimpleLineSymbol("dashdot", new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25])); var graphic = new esri.Graphic(geometries[0],symbol); map.graphics.add(graphic);
// +++++Listen for QueryTask executecomplete event+++++ dojo.connect(queryTask, "onComplete", function(fset) { //create symbol for selected features var symbol = new esri.symbol.SimpleMarkerSymbol(); symbol.style = esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE; symbol.setSize(8); symbol.setColor(new dojo.Color([255,255,0,0.5]));
//var infoTemplate = new esri.InfoTemplate("Block: ${BLOCK}", "${*}"); var resultFeatures = fset.features; for (var i=0, il=resultFeatures.length; i<il; i++) { console.log(resultFeatures) var graphic = resultFeatures; graphic.setSymbol(symbol); map.graphics.add(graphic); } var recordnums = returnRecordNums(fset); var r = ""; r = "<b>The record numbers within the buffer are <i>" + recordnums + "</i>.</b>"; dojo.byId('messages').innerHTML = r; });
function returnRecordNums(fset){ var features = fset.features; var record_nums = ""; for (var x = 0; x < features.length; x++) { record_nums = record_nums + ", " + features.attributes['record_number']; } return record_nums; }