ArcGIS API-不支持执行QueryTask [英] ArcGIS API - Execute QueryTask unsupported

查看:246
本文介绍了ArcGIS API-不支持执行QueryTask的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在使用ArcGIS API(javascript),以便从要素图层中的对象获取一些信息.这里的第一步应该是检测用户单击了哪个对象.我为此使用查询.但是由于某种原因,我似乎无法执行查询.每次调用execute方法时,控制台都会答复"Object不支持属性或方法'execute'".该代码的相关部分如下:

So, I am using the ArcGIS API (javascript) in order to get some information from objects in a featurelayer. The first step here should be detecting which object the user clicked. I am using queries for this. For some reason though, I cannot seem to execute my queries. Every time the execute method is called, the console replies that "Object doesn't support property or method 'execute'". The relevant part of the code is as follows:

thema_4_Verblijf = new FeatureLayer("https://services.arcgisonline.nl/arcgis/rest/services/Basisregistraties/BAG/MapServer/4");
        map_Thema_4.addLayer(thema_4_Verblijf);
        thema_4_Verblijf.on("click", thema_4_Verblijf_Click);
        function thema_4_Verblijf_Click(evt){
            var query = new Query();
            query.returnGeometry = true;
            query.outFields = ["*"];
            query.geometry = evt.mapPoint;
            var queryTask = new QueryTask("https://services.arcgisonline.nl/arcgis/rest/services/Basisregistraties/BAG/MapServer/4");
            queryTask.execute(query,showResults);
        };

        function showResults(featureSet){
            //will show results
        }

起初,我认为这与我在脚本开始时未正确定义需求有关.尽管execute是QueryTask的一种方法,但是这不可能实现,并且"new QueryTask"本身可以完成而没有任何错误.尽管如此,我定义的要求是:

At first, I thought this had to do with me not defining the requirements correctly at the start of the script. This cannot be possible though as execute is a method of QueryTask, and 'new QueryTask' itself completes without any errors. Nonetheless, my requirements as defined are:

require([...
    "esri/geometry",
    "esri/tasks/query",
    "esri/tasks/QueryTask",
    "esri/tasks/FeatureSet"
    ],
    function startMap(
    ...
    Query,
    QueryTask,
    ...

任何关于这里可能出问题的想法...?

Any thoughts on what could be wrong here...?

推荐答案

好的,所以已经回答了..

Alright, so this has been answered..

我尝试使用旧版模块定义querytask,并且由于某些原因而起作用.

I tried defining querytask with the legacy module and for some reason that worked.

var queryTask = new esri.tasks.QueryTask(...);

在我当前的项目中,即使我的所有要求都是使用AMD方式定义的,也必须将旧有的模块和AMD模块混为一谈.

I have experienced this before during my current project, somewhere legacy and AMD modules must be mixed up, even though all my requires have been defined using the AMD way.

是的,这个特定的问题已得到解决(例如:我可以继续),但是如果有人可以解释如何将两个模块混合使用,那将不胜感激.

So yes, this particular question has been fixed (as in: I can continue) but if someone could explain how the two modules can get mixed up, that would be appreciated.

这篇关于ArcGIS API-不支持执行QueryTask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆