在我的表單中,我有選項卡類型Togglable tabs
前端Bootstrap。每次點擊標籤頁,我需要顯示地圖,不幸的是顯示在灰色的部分。使用的代碼:地圖顯示爲灰色
@Using Ajax.BeginForm("Index", New AjaxOptions() With { _
.UpdateTargetId = "AnswerSN",
.HttpMethod = "POST"
})
@<Script>
init("tab1");
function ChangeDiv(whoDiv) {
if (whoDiv.href.indexOf("#tab1") != -1) {
$(".mezzouno").attr("id", "old-map")
$(".flottauno").attr("id", "basic-map")
clearTimeout(TimeR)
init("tab1");
} else if (whoDiv.href.indexOf('#mezzo1') != -1) {
$(".flottauno").attr("id", "old-map")
$(".mezzouno").attr("id", "basic-map")
clearTimeout(TimeR)
init("mezzo1");
}
}
var TimeR;
function Fleet() {
var updateUrl = '@Url.Action("FleetVb", "Home")';
$.ajax({
url: updateUrl,
success: function (result) {
FleetJs(result);
},
cache: false
});
clearTimeout(TimeR)
TimeR= window.setTimeout("Fleet()", 60000);
}
function Vehicle() {
var updateUrl = '@Url.Action("PointVb", "Home")';
$.ajax({
url: updateUrl,
success: function (result) {
initialize(result);
},
cache: false
});
clearTimeout(TimeR)
TimeR= window.setTimeout("Vehicle()", 60000);
}
function init(whoDiv) {
var myOptions = {
zoom: 8,
center: new google.maps.LatLng(41.895122, 12.481627),
mapTypeId: google.maps.MapTypeId.ROADMAP,
panControl: true,
panControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
},
streetViewControl: false,
scaleControl: true
};
map = new google.maps.Map(document.getElementById("basic-map"), myOptions);
google.maps.event.trigger(map, 'resize');
if (whoDiv== 'tab1') {
window.setTimeout("ProvaFlotta()", 1000);
} else if (whoDiv== 'mezzo1') {
window.setTimeout("Prova()", 1000);
}
}
</script>
@<div id="AnswerSN" style="position:absolute; top:100px"></div>
End Using
在哪裏處理標籤的點選並根據它和查詢地圖的id? 不幸的是,我得到這個:
可以調出完整的地圖,而不是灰色的?
這可能是一個CSS問題: http://stackoverflow.com/questions/9141249/twitter-bootstrap-css-affecting-google-maps – SebastianStehle
的代碼部分,其初始化地圖即可。它顯示縮放後的意大利和羅馬地區。檢查您的地圖樣式設置。 –
好的,擴大瀏覽器窗口的地圖將恢復正常,這是可見的,點擊標籤返回到灰色的可見部分,並將窗口放大到100%可見。 你可以使它始終可見的點擊? –