2016-06-14 1 views
0

J'ai été testé à l'IdentyfyTask.comment obtenir arcgis IdentyfyTask addCallback `valeur?

Mais je ne pouvais pas obtenir de réponse avant la valeur addCallback.

Je veux les valeurs de pnu.

Mais PNU vaule était tousjours non définie ...

mon code est suit.

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; 
    } 

Les résultats étaient les suivants.

enter image description here

Répondre

1

IdentifyTask retourne un objet IdentifyResult. donc vous codez réponse [0] .value sera indéfini. vous devez utiliser quelque chose comme réponse [0] .feature.attributes.PNU

+0

Mais regardez à partir de la console d'outils de développement Chrome peut vérifier la valeur PNU – BingBingPa