2012-07-23 51 views
0

嗨我有一個地圖代碼的麻煩......我使用drawingManager創建標記,但我想顯示或隱藏取決於複選框,但我不知道如何做到這一點...可以有人幫幫我!!非常感謝!顯示和隱藏標記畫畫管理器

回答

0

您需要3部分代碼才能做到這一點。

1)下面是顯示層的代碼(I假設你有這樣的話):)正下方顯示層代碼

var parcel_boundary = new google.maps.FusionTablesLayer({ 
query: { 
    select: 'parcel_boundary_1_9999', 
    from: '1ouLS0fm8tPPQNQRpr-bwE4ct-cBkMB-Ru_XttDQ' 
    }, 
    styles: [{ 
    polygonOptions: { 
    strokeColor: "#333333", 
    strokeOpacity: 0.8, 
    strokeWeight: 0.7, 
    fillColor: "#36549C", 
    fillOpacity: 0.3 
    } 
}], 
    //map: map, 
    suppressInfoWindows: true 
    }); 
    google.maps.event.addListener(parcel_boundary, 'click', function(e) { 
    windowControl(e, infoWindow, map); 
}); 

2自帶這部分代碼:

$('#parcel_boundary_box').click(function(){ 
    if ($(this).is(':checked')) 
    parcel_boundary.setMap(map); // show 
    else 
    parcel_boundary.setMap(null); // hide 
    }); 
$('#parcel_boundary_box').removeAttr('disabled'); 

3 )並在體內你需要添加此代碼:

<div id="panel" style="position:absolute; left:560; top:0px; width:140px; height:30px;"> 
<input type="checkbox" id="parcel_boundary_box" disabled="true"> 
<span class="style2">Parcel Boundary</span> 
</div> 

我希望我幫你。

最好的, Darko