ArcGIS API - Execute QueryTask unsupported

拟墨画扇 提交于 2019-12-25 03:52:39

问题


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
        }

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...?


回答1:


Alright, so this has been answered..

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

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

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.



来源:https://stackoverflow.com/questions/33766736/arcgis-api-execute-querytask-unsupported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!