在用QueryTask查询的时候总是查询不到数据,可是明明有数据的啊?求大神帮忙看看是哪里的问题=,=
require([
"dojo/parser",
"esri/map",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/InfoTemplate",
"esri/tasks/QueryTask",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/TextSymbol",
"esri/toolbars/draw",
"esri/tasks/query",
"esri/graphic",
"dojo/domReady"
], function (parser,Map, ArcGISDynamicMapServiceLayer, InfoTemplate, QueryTask, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, TextSymbol, Draw, Query, Graphic) {
parser.parse();
//添加地图
var map=new Map("mapDiv");
var serviceURL = "http://localhost:6080/arcgis/rest/services/pingru/pingru/MapServer";
var layer = new ArcGISDynamicMapServiceLayer(serviceURL);
map.addLayer(layer);
wkid = 4326;
//实例化infotemplate
infoTemplate = new InfoTemplate("${OBJECTID}", "名称:${OBJECTID}")
//建立Querytask查询任务
querytask = new esri.tasks.QueryTask(serviceURL + "/0")//查询GPS站点图层
//建立toolbar
toolbar = new Draw(map);
pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 12, new dojo.Color(["#ff0000"]));
toolbar.activate(Draw.POLYGON);
query = new esri.tasks.Query();
//为toolbar绑定完成事件
toolbar.on("draw-complete", function (geometry) {
//IsGraphicQuery = false;
//ClearGraphic();
QueryGraphic(geometry);
toolbar.deactivate();
})
//空间查询
function QueryGraphic(evt) {
query.geometry =evt.geometry;
//query.outSpatialReference = map.spatialReference;//加了就出BUG
query.spatialRelationship = Query.SPATIAL_REL_CONTAINS;
query.returnGeometry = true;
query.outFields = ["Elevation"];
querytask.execute(query, ShowQueryResult)
//document.getElementById("showResultDiv").innerHTML = "未找到结果";
var polygonSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255, 0, 0]), 1), new dojo.Color([255, 0, 0, 0.25]));
var graphicPolygon = new Graphic(evt.geometry, polygonSymbol);
map.graphics.add(graphicPolygon);
}
function ShowQueryResult(queryResult) {
if (queryResult.features.length == 0) {
document.getElementById("showResultDiv").innerHTML = "未找到结果"
}
打断点之后如图所示,没有数据![图片说明](https://img-ask.csdn.net/upload/201704/07/1491563015_197168.png)
但是发布的地图里的属性是有数据的![图片说明](https://img-ask.csdn.net/upload/201704/07/1491563156_531119.png)
求大神帮忙看下哪里的问题,是代码的问题还是我发布地图服务的时候的问题