2016-11-08 85 views
0

在我的arcgis javascript地图中,我必须在地图上标识用户在地图上单击的位置。在地图中,除底图图层外没有添加图层。我有10个地图图层,在做IdentifyTask和结果返回时,我将这些图形添加到地图上。作为回报graphis我也添加了infoTemplate。InfoWindow不显示多个图形属性

当用户点击任何图形时,它仅显示所选图形的属性,但没有任何默认的分段设置,因此我还可以看到重叠的图形结果。

identifyFeatures:function(evt){ 
     var rslts=[]; 
     _.each(this.identifablelayers,function(layer){ 
      var fT=new IdentifyTask(layer.get('url'));    
      var params = new IdentifyParameters(); 
      params.tolerance = this.mapv.setting.idetifyTolerance; 
      params.layerIds = [0]; 
      params.layerOption = "top"; 
      params.returnGeometry = true; 
      params.width = this.mapv.map.width; 
      params.height = this.mapv.map.height; 
      params.layerOption = IdentifyParameters.LAYER_OPTION_ALL; 
      params.geometry = evt.mapPoint; 
      params.mapExtent = this.mapv.map.extent; 
      var result=fT.execute(params);    
      rslts.push(result); 
     },this); 
     all(rslts).then(this.identifyFeaturesCallBack,this.handleQABfClBErr,this.handleIdentifyProgress); 
}, 
identifyFeaturesCallBack:function(response){    
     var features=[];    
     _.each(response,function(lyresponse,i){ 
      var lyr=this.identifablelayers[i]; 
      _.each(lyresponse, function(ftr) { 
       var graphic=ftr.feature; 

       if(lyr.get('template')!=undefined && lyr.get('template')!=null){         
        var template=new InfoTemplate(lyr.get('name'), lyr.get('template'));       
        graphic.setInfoTemplate(template); 
       }else{ 
        var template=new InfoTemplate(lyr.get('name'), "${*}");       
        graphic.setInfoTemplate(template); 
       } 
       var smb= this.mapv.smbl.roadSearchSymbol; 
       if(lyr.get('layercolor')!=undefined && lyr.get('layercolor')!=null){ 
        if(graphic.geometry.type=='polyline'){ 
         smb= new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,this.mapv.convertHexToColor(lyr.get('layercolor'),100), this.mapv.setting.lineWidth); 
         if(lyr.get('name').toUpperCase()=='BRIDGES' || lyr.get('name').toUpperCase().indexOf('BRIDGE')>=0){ 
          smb= new SimpleLineSymbol(SimpleLineSymbol.STYLE_SHORTDASH,this.mapv.convertHexToColor(lyr.get('layercolor'),100), parseInt(this.mapv.setting.lineWidth) + parseInt(this.mapv.setting.extraBridgeWidth)); 
         } 
        }else if(graphic.geometry.type=='polygon'){ 
         smb= this.mapv.smbl.plmPolygonDefaultSymbol;        
         var symbolPolygonDefaultLn=new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, this.mapv.convertHexToColor(lyr.get('layercolor'),100), this.mapv.setting.polygonWidth); 
         smb = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, symbolPolygonDefaultLn, null);        
        }else if(graphic.geometry.type=='point'){ 
         smb=this.mapv.smbl.plmPointHighLightSymbol; 
         smb=new SimpleMarkerSymbol(
         SimpleMarkerSymbol.STYLE_SQUARE, this.mapv.setting.pointWidth, 
         new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, this.mapv.convertHexToColor(lyr.get('layercolor'),100), 4), 
         this.mapv.convertHexToColor(lyr.get('layercolor'),100)); 
        } 
       } 
       graphic.setSymbol(smb); 
       this.mapv.map.graphics.add(graphic); 
       this.resultCache.push(graphic);  
       features.push(graphic); 

      }.bind(this)); 

     }.bind(this)); 

     this.activeInactive(null,true); 
     this.removeHandlers(false,'click'); 
    }, 

我试图通过向infowindow添加功能,但它不起作用。它只适用于将所有这10个图层添加到地图上,然后尝试在地图上做Idenity。通过这个,我在默认情况下在Infowindow头部得到默认的<>。突出显示图形也默认移动,甚至图形重叠。

回答

0

有一个在map.infoWindow称为setFeatures功能,您可以使用弹出窗口,以允许通过结果页面,设置它的一个例子是

var deferred = identifyTask 
            .execute(identifyParams) 
            .addCallback(function (response) { 
    // response is an array of identify result objects 
    // Let's return an array of features. 
    return arrayUtils.map(response, function (result) { 
     var feature = result.feature;  
     feature.attributes.layerName = result.layerName; 
     var taxParcelTemplate = new InfoTemplate("", 
     "${Postal Address} <br/> Owner of record: ${First Owner Name}"); 
     feature.setInfoTemplate(taxParcelTemplate); 
     return feature; 
    }); 
}); 

// InfoWindow expects an array of features from each deferred 
// object that you pass. If the response from the task execution 
// above is not an array of features, then you need to add a callback 
// like the one above to post-process the response and return an 
// array of features. 
map.infoWindow.setFeatures([deferred]); 
map.infoWindow.show(event.mapPoint); 

的API参考是https://developers.arcgis.com/javascript/3/jsapi/popup-amd.html#setfeatures

+0

我在我的代码中使用setFeatures之前,仍然遇到问题,当用户点击任何不显示其他图形的图形时。这是什么东西到每个图形明确的信仰设置? – akirti