时间:2020.10.13
报错情况:
(index):2233 Uncaught TypeError: Cannot read property 'query' of undefined
at Object.execute ((index):2233)
at Object.c.<computed> [as execute] ((index):1220)
at queryparame (main.html:93)
at main.html:74
at ja ((index):28)
at (index):29
at ka ((index):28)
at ha ((index):28)
at q ((index):31)
at HTMLScriptElement.<anonymous> ((index):35)
原因:
var tpgkUrl = "http://localhost:6080/arcgis/rest/services/MyMapService/MapServer/2";
var queryTask = new QueryTask({
url: tpgkUrl
});
var query = new Query();
改为:
var queryTask = new QueryTask("http://localhost:6080/arcgis/rest/services/MyMapService/MapServer/2");
时间:2020.10.13
问题:
function queryparame(dysf, areaparameter) {
console.log(dysf);
console.log(areaparameter);
var queryTask = new QueryTask("http://localhost:6080/arcgis/rest/services/MyMapService/MapServer/2");
var query = new Query();
query.where = "基本单元码=\'" + dysf + "\'";
//返回所有字段
query.outFields = ["*"];
//返回几何信息。
query.returnGeometry = true;
queryTask.execute(query, function(results) {
console.log(results);
console.log("你好");
});
}
这一段代码,有什么问题那????,看似没问题,但是就是没有输出结果,我一开始调试的时候,代码直接跳过function函数,我以为没有执行function函数里面的代码,就以为是query.where = “基本单元码=’” + dysf + “’”;这段查询条件写的有问题。搞了好久,最后发现,是我按F10直接跳过函数.execute,输出results这行代码就没执行(泪奔)。console.log(“你好”);也没有执行。
const featurelayer = new FeatureLayer({
url: "http://localhost:6080/arcgis/rest/services/xygy/MapServer"
});
问:使用FeatureLayer加载地图为什么只加载出来一个图层???
答:因为 FeatureLayer只能加载图层,怎么加载地图,你告诉我。
ArcGIS API for JavaScript开发好多坑,一不小心就掉进去了。而且花很长时间也不一定能找到~~~///(v)\~~~。
持续更新···························································