我已接受 IdentyfyTask 测试。
但是在值addCallback之前我无法得到响应。
我想要 pnu 值。
但 pnu vaule 始终未定义...
我的代码如下。
function poiClick(){
agmap.addEvent("click", function(evt){
getPoi= krcgis.Function.PoiClick(agmap ,evt);
console.log("X === ",getPoi.x);
console.log("Y === ",getPoi.y);
console.log("PNU === ",getPoi.pnu);
});
}
PoiClick : function(map, evt) {
poiInfo = {};
poiInfo.x =evt.mapPoint.x;
poiInfo.y =evt.mapPoint.y;
var targetLayerId = 'LP_PA_CBND';
var url = map.Layers.getLayerInfo(targetLayerId).SVC_URL;
var map = map.getMap();
//파라미터 설정.
var idParams = new krcgis.core.tasks.IdentifyParameters();
idParams.geometry = evt.mapPoint;
idParams.mapExtent = map.extent;
idParams.returnGeometry = true;
idParams.tolerance = 0;
idParams.layerOption = krcgis.core.tasks.IdentifyParameters.LAYER_OPTION_ALL;
idParams.width = map.width;
idParams.height = map.height;
idTask = new krcgis.core.tasks.IdentyfyTask(url);
idTask
.execute(idParams)
.addCallback(function (response) {
if (response) {
poiInfo.pnu =response[0].value;
}
});
return poiInfo;
}
结果如下。
最佳答案
IdentifyTask 返回一个IdentifyResult 对象。所以你的代码 response[0].value 将是未定义的。 您应该使用类似 response[0].feature.attributes.PNU
关于javascript - 如何获取 arcgis IdentyfyTask addCallback 的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37810006/