简体   繁体   English

如何修复TypeError:在ArcGIS JS API(查询)中未定义this._url

[英]How to fix TypeError: this._url is undefined in ArcGIS JS API (Query)

I'm tasked with developing a custom widget for ArcGIS' Web App Builder and i've been trying to get a Query to work using the ArcGIS Javascript API 3.28 so i can build a report using layer information. 我的任务是为ArcGIS的Web App Builder开发一个自定义小部件,我一直在尝试使用ArcGIS Javascript API 3.28来查询,以便我可以使用图层信息构建报告。 But upon attempting to test the query by means of a button, i get a TypeError: this._url is undefined. 但是在尝试通过按钮测试查询时,我得到一个TypeError:this._url是未定义的。


define(['dojo/_base/declare', 'jimu/BaseWidget',
        'jimu/dijit/Report', 'esri/layers/FeatureLayer',
        'jimu/dijit/PageUtils', 'dijit/_WidgetsInTemplateMixin', 'esri/tasks/IdentifyTask',
        'esri/tasks/IdentifyParameters', 'esri/symbols/SimpleFillSymbol', 'esri/symbols/SimpleLineSymbol',
        'esri/graphic', 'esri/Color', 'dojo/_base/lang',
        'dojo/_base/html', 'dojo/on', 'dojo/domReady!',
        'esri/tasks/QueryTask', 'esri/tasks/query'],

function(declare, BaseWidget, Report, FeatureLayer,
        PageUtils, _WidgetsInTemplateMixin, IdentifyTask, IdentifyParameters,
        SimpleFillSymbol, SimpleLineSymbol, Graphic,
        Color, lang, on, Query, QueryTaskTest) {

  var baseWidgetClass = declare([BaseWidget], {
    baseClass: 'jimu-widget-demo',

    postCreate: function() { // POST CREATE!
      this.inherited(arguments);
      this.map.infoWindow.hide();
    },

    startup: function() {
      this.inherited(arguments);
      console.log('startup');
    },

    onClose: function(){
      console.log('onClose');
    },

    _onBtnPrintClicked: function(){
    console.log("Begin query test");
    var queryUrl = "https://webportalurl/arcgis/rest/services/ServiceName/MapServer/0";
    var queryTask = new QueryTaskTest(queryUrl);
    var query = new Query();
    query.returnGeometry = false;
    query.outFields = ["*"];
    query.where = "HAB_IPTU = 2089358";
    console.log("Running execute");

    queryTask.execute(query).then(function(results){
      console.log(results.features[0]);
    });
  }

  });
  return baseWidgetClass;
});

QueryTask on api 3.28 expects the url as String : https://developers.arcgis.com/javascript/3/jsapi/querytask-amd.html#querytask1 api 3.28上的QueryTask期望url为Stringhttps//developers.arcgis.com/javascript/3/jsapi/querytask-amd.html#querytask1

Try this : 尝试这个 :

var queryTask = new QueryTask(queryUrl);

or 要么

var queryTask = new QueryTask("MapServerUrl");

The problem has nothing to do with the QueryTask or how you are calling it. 问题与QueryTask或您如何调用它无关。 The arguments in the define statement and function definition do not match up. define语句和函数定义中的参数不匹配。

'dojo/_base/lang', matches up with lang in the function but then 'dojo/_base/html' matches up with the on, 'dojo/on' matches up with Query and finally 'dojo/domReady!' 'dojo / _base / lang',与函数中的lang匹配,但'dojo / _base / html'与on匹配,'dojo / on'与Query匹配,最后匹配'dojo / domReady!' matches up with QueryTaskTest. 与QueryTaskTest匹配。 use the modules that don't require a corresponding constructor at the end of the define list otherwise you have to include them in the function definition to preserve the order. 在定义列表的末尾使用不需要相应构造函数的模块,否则必须将它们包含在函数定义中以保留顺序。

like this 像这样

    define(['dojo/_base/declare',
        'jimu/BaseWidget',        
        'jimu/dijit/Report', 
        'esri/layers/FeatureLayer',
        'jimu/dijit/PageUtils',
        'dijit/_WidgetsInTemplateMixin',
        'esri/tasks/IdentifyTask',
        'esri/tasks/IdentifyParameters', 
        'esri/symbols/SimpleFillSymbol', 
        'esri/symbols/SimpleLineSymbol',
        'esri/graphic', 
        'esri/Color', 
        'dojo/_base/lang',
        'dojo/on',        
        'esri/tasks/query',
        'esri/tasks/QueryTask',
        'dojo/_base/html', //these last two are at the end
        'dojo/domReady!'], //because they don't need to be called or instantiated directly.

    function(declare, 
        BaseWidget, 
        Report, 
        FeatureLayer,
        PageUtils, 
        _WidgetsInTemplateMixin,
        IdentifyTask,
        IdentifyParameters,
        SimpleFillSymbol,
        SimpleLineSymbol,
        Graphic,
        Color,
        lang,
        on,
        Query,
        QueryTaskTest) { ....});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:this._url在Dojo FilteringSelect onChange回调中未定义 - TypeError: this._url is undefined at Dojo FilteringSelect onChange callback dojo解析器和使用ArcGIS JS API的TypeError - dojo parser and a TypeError using ArcGIS JS API 如何修复“TypeError:_this is undefined” - How to fix “TypeError: _this is undefined” mysql node.js 查询错误(未定义)? 如何修复它 - mysql node.js query error(undefined)? how to fix it 如何修复“ TypeError: undefined is not an object (evaluating 'subitem.media_details.sizes.medium.source_url') ' - How to fix ' TypeError: undefined is not an object (evaluating 'subitem.media_details.sizes.medium.source_url') ' 如何在导入期间修复“ TypeError:未定义不是对象” - How to fix 'TypeError: undefined is not an object' during import 如何修复“TypeError: undefined is not an object”? - How can I fix 'TypeError: undefined is not an object'? 如何修复TypeError:undefined不是对象错误? - How to fix TypeError: undefined is not an object error? ArcGIS Javascript API-如何使用jquery ajax获取地图URL - ArcGIS Javascript API - how to get map url using jquery ajax 如何解决:“TypeError:无法读取discord.js中未定义的属性'标签'错误 - How to fix: “TypeError: Cannot read property 'tag' of undefined” error in discord.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM