2013-10-10 56 views
0

我使用的是ArcGIS JavaScript 3.7 API,我使用的是agsjs.dijit.TOC控件,它工作正常,但是當我在地圖中添加標籤層時,標籤圖層會很好,但TOC工作不正常。在ArcGIS中使用標籤圖層的TOC JavaScript

同時按下複選框通斷層是工作正常,但對於我補充說,沒有得到開 - 關一個標記物層的功能層

誰能告訴我如何切換,關閉或開啓標籤層。

在此先感謝。

我粘貼一些代碼..

 Var load = function() { 
    require(["dojo/_base/Color", "esri/symbols/TextSymbol", "esri/renderers/SimpleRenderer", "esri/renderers/ScaleDependentRenderer"], 
    function (Color, TextSymbol, SimpleRenderer, ScaleDependentRenderer) { 
    var statesColor = new Color("#666"); 
    var fieldLabel = new TextSymbol().setColor(statesColor); 
    fieldLabel.font.setSize("4pt"); 
    fieldLabel.font.setFamily("arial"); 

    statesLabelRenderer = new SimpleRenderer(fieldLabel); 
    return statesLabelRenderer; 
}); 
    } 
    var layers = []; 
    var layer = new esri.layers.FeatureLayer(url, { 
     mode: esri.layers.FeatureLayer.MODE_ONDEMAND, 
     outFields: ["*"]          
    }); 
    layers.push(layer); 

    layerInfo.push({ layer: layer, title: item["LookupDisplayDesc"], boxLabel: item["LookupDisplayDesc"], id: layer.id, checked: layer.visibleAtMapScale, slider: true }); 

if (item["LookupLongDesc"] != null && item["LookupLongDesc"] != "") { 
    var fieldNames = item["LookupLongDesc"].split(","); 
    var labelFields = ""; 
for (var i = 0 ; i < fieldNames.length ; i++) { 
    labelFields = labelFields + "${" + fieldNames[i].trim() + "},"; 
} 
    labelFields = labelFields.slice(0, -1).trim(); 
    load(); 
    var labelLayer = new esri.layers.LabelLayer(); 
    labelLayer.addFeatureLayer(layer, statesLabelRenderer, labelFields); 
    layers.push(labelLayer); 
    } 
} 
map.addLayers(layers); 


dojo.connect(map, 'onLayersAddResult', function (results) { 
       if (layerInfo.length > 0) { 
        var legendDijit = new esri.dijit.Legend({ 
         map: map, 
         layerInfos: layerInfo 
        }, "legendDiv"); 
        legendDijit.startup(); 
       } 
       toc = new agsjs.dijit.TOC({ 
        map: map, 
        layerInfos: layerInfo 
       }, 'LayerDiv'); 
       toc.startup();     
      }); 
+0

好我等待答覆... –

回答

1

不熟悉TOC是如何工作的,我手動建立我的層邏輯。如果你去手動路線,你可以使用顯示和隱藏像下面一樣,或使用setVisibleLayers像this

一個簡單的顯示和隱藏在你的層邏輯是:

labelLayer.hide(); 
labelLayer.show(); 
相關問題