InfoWindow未显示多个图形属性

时间:2016-11-08 16:49:29

标签: arcgis arcgis-js-api

在我的arcgis javascript地图中,当用户点击Map时,我必须在地图上识别。在地图中,除了底图图层之外没有添加任何图层。我有10个地图图层在做IdentifyTask时,当结果返回时,我将这些图形添加到地图中。作为回报graphis我也添加了infoTemplate。

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

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标题处。突出显示图形也默认移动,即使图形重叠。

1 个答案:

答案 0 :(得分:0)

setFeatures上有一个名为map.infoWindow的函数,您可以将其用于弹出窗口以允许对结果进行分页,设置它的示例是

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