2016-11-08 2 views
0

In meiner arcgis Javascript Map muss ich auf der Karte identifizieren, wenn der Benutzer auf Map klickt. In der Karte sind keine Layer außer der Grundkartenebene hinzugefügt. Ich habe 10 Kartenlayer, auf denen IdentifyTask ausgeführt wird, und wenn das Ergebnis zurückgegeben wird, füge ich diese Grafiken zum Map hinzu. Im Gegenzug dazu füge ich auch infoTemplate hinzu.InfoWindow zeigt nicht mehrere Grafikattribute an

Wenn ein Benutzer auf eine Grafik klickt, zeigt er nur die Attribute für die ausgewählte Grafik an, hat aber keine Standard-Seitenfunktion, so dass ich auch die überlagerten Grafiken sehen kann.

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'); 
    }, 

Ich versuchte durch Hinzufügen von Funktionen zu Infowindow auch, aber es funktioniert nicht. Es funktioniert nur, wenn ich alle diese 10 Ebenen zum Map hinzufügen und dann versuchen, Idenity auf der Karte zu machen. damit bekomme ich standardmäßig den Default <> im Infowindow Header. Hervorhebungsgrafik bewegt sich standardmäßig auch wenn Grafiken sich überlappen.

Antwort

0

Es gibt eine Funktion setFeatures auf dem map.infoWindow genannt, die Sie für das Popup verwenden können Paging durch die Ergebnisse zu ermöglichen, ein Beispiel es der Einstellung ist

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

Die API-Referenz bei https://developers.arcgis.com/javascript/3/jsapi/popup-amd.html#setfeatures

+0

I used setFeatures in meinem Code, bevor ich noch das Problem sah, wenn der Benutzer auf irgendeine Grafik klickt, die andere nicht anzeigt. Ist das etwas mit expliziter Infotemplate-Einstellung für jede Grafik? – akirti

Verwandte Themen