ArcGIS API for Javascript QuertTask查询不到数据

在用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)
                            求大神帮忙看下哪里的问题,是代码的问题还是我发布地图服务的时候的问题

3个回答

找到问题所在了,这是因为ArcGIS server 10.2本身固有的BUG导致的,据说10.3以后修复这个BUG了。如果不想换成10.3的话建议在后端写个查询程序,然后返回Json给前端

weixin_40570285
centerpig 请问你怎么解决的
一年多之前 回复

图片说明

图片说明

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐