Maps 打开和关闭贴图层

Maps 打开和关闭贴图层,maps,arcgis,esri,arcgis-server,Maps,Arcgis,Esri,Arcgis Server,如果这不是一个问题,那就是另一个问题。我看了一整天,不知道这里出了什么问题。我又有一张地图,有两层,一层是县级,一层是msa。我在页面上有两个链接,一个是county,另一个是msa。单击任一链接,我想关闭地图的一个图层,并显示在正确的图层上。以下是单击事件: $('.map-type-link').live('click', function () { params.display_region_type = parseInt($(this).attr('region_type'));

如果这不是一个问题,那就是另一个问题。我看了一整天,不知道这里出了什么问题。我又有一张地图,有两层,一层是县级,一层是msa。我在页面上有两个链接,一个是county,另一个是msa。单击任一链接,我想关闭地图的一个图层,并显示在正确的图层上。以下是单击事件:

$('.map-type-link').live('click', function () {
    params.display_region_type = parseInt($(this).attr('region_type'));

    if (params.display_region_type == 1) {

        app.currentFl = app.featureLayers[0];

    }
    else {

        app.currentFl = app.MSAfl;            
        app.flVis.setVisibility(false);
        app.MSAfl.setVisibility(true);
        app.currentFl.redraw();                        

    }                 
}))

右键不只是单击县,app.flvis仍然可见

在此处创建要素图层:

dojo.forEach(app.layersUrls, function (info, idx) {
    app.featureLayers[idx] = new esri.layers.FeatureLayer(
        app.layersUrls[idx], {
            mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
            outFields: app.outFields[idx],
            opacity: 0.80
            }
        );       

    app.featureLayers[idx].setRenderer(br);

    //create min and max scales when layers load
    dojo.connect(app.featureLayers[idx], 'onLoad', function () {
        app.featureLayers[idx].minScale = app.layerScales[idx].min;
        app.featureLayers[idx].maxScale = app.layerScales[idx].max;
    });//ends connections 

    //add THIS feature layer to the map
    app.map.addLayer(app.featureLayers[idx]);
(我正在对所有变量的含义进行假设。)

要打开MSA层,您有四行代码(在else语句中):

在if语句中,您只有一行代码,这行代码不会打开或关闭任何层:

app.currentFl = app.featureLayers[0];
相反,我认为您需要遵循您在else语句中所做的示例:

app.currentFl = app.MSAfl;            
app.flVis.setVisibility(false);
app.MSAfl.setVisibility(true);
app.currentFl.redraw();
app.currentFl = app.flVis;            
app.MSAfl.setVisibility(false);
app.flVis.setVisibility(true);
app.currentFl.redraw();

这假设app.flVis是您的县级图层,可能是这样,也可能不是这样。

是一个更大的问题,为什么它不只是隐藏预期的图层