我已经尝试了一切。我无法在联系人选项卡处于活动状态时加载此地图。没有人能弄明白为什么这对我不起作用。你能?我将发布我的所有代码,因为采取片段并没有带来解决方案。请原谅我未完成的代码和格式。初始化地图的脚本位于头部,联系人选项卡位于html页面的底部。
HTML:
body {
padding-top: 50px;
background-color: #777
}
h1, h2, h3 {
margin-top: 0;
margin-bottom: 0;
}
.starter-template {
padding: 40px 15px;
text-align: center;
}
.navbar.navbar-inverse.navbar-fixed-top {
position: absolute;
background-color: #336699;
border: 0px;
height: 51px;
margin-top: 120px;
}
/*.nav.nav-pills{
}*/
.nav.nav-pills li a{
color: white;
font-family: Roboto, Titillium Web, Arial, Verdana, sans-serif;
padding-left: 76px;
padding-right: 76px;
font-size: 22px;
margin-top: 0px;
}
.nav-pills li a:hover{
color: grey;
}
.navbardos.navbar-inverse.navbar-fixed-top {
position: absolute;
background-color: black;
border: 0px;
height: 120px;
}
.nav.navbar-navdos{
float: right;
font-size: 13px;
margin-top: 30px;
margin-right: 24px;
width: 200px;
}
.nav.navbar-navdos li a{
padding:0px;
color: white;
}
.nav.navbar-navdos li a:hover{
background-color: black;
}
.number {
font-size: 30px;
}
.logo {
width: 400px;
margin-left: -130px;
}
#home{
margin-top: 100px;
position: absolute;
}
#about{
margin-top: 150px;
width:100%
}
#services{
margin-top: 150px;
position: absolute;
}
#portfolio{
margin-top: 150px;
position: absolute;
}
#contact{
font-family: Titillium Web, Arial, Verdana, sans-serif;
color: #E8E8E8;
}
#contact-content{
position: absolute;
float: left;
margin-top: 176px;
margin-left: 100px;
}
#map {
margin-left: 650px;
margin-top: 180px;
position: absolute;
float: right;
width: 550px;
height: 400px;
}
/* Carousel base class */
.carousel {
margin-left: 30px;
height: 500px;
width: 100%;
margin-bottom: 60px;
margin-top: 20px;
}
/* Since positioning the image, we need to help out the caption */
.carousel-caption {
height: 500px;
}
.btn.btn-lg.btn-primary {
background-color: #FF9900 ;
}
.btn.btn-lg.btn-primary:hover {
background-color: #B22400 ;
}
/* Declare heights because of positioning of img element */
.carousel .item {
height: 800px;
background-color: #777;
}
.carousel-inner > .item > img {
position: fixed;
top: 0;
left: 0;
min-width: 100%;
height: 800px;
}
.carousel-control.right, .carousel-control.left {
background-image:none;
margin-top: 200px;
}
CSS:
<script>
function initialize() {
var mapCanvas = document.getElementById('map');
var myLatLng = {lat: 64.8370761, lng: -147.697845};
var mapOptions = {
center: myLatLng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(mapCanvas, mapOptions)
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: "Nelson's Photography"
});
}
google.maps.event.addDomListener(window, 'click', initialize);
</script>
当我以这种方式编写代码时,地图将在单击时加载,因此我知道它不是不正确地加载引导程序库:
<XmlDataProvider x:Key="ProductsXml" Source="{Binding OpenRecordMenuItem_Click}"/>
答案 0 :(得分:0)
问题的解决方案是将我的所有脚本移到html页面的底部。正如您在上面所看到的,一些脚本位于头部的顶部,其中一些脚本位于正文的底部。将它们一起移动到正文中允许这段代码正常工作:
$('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
initialize();
});
@Mathemats如果我没有在我的其他帖子(Google map in a bootstrap tab - specific code)中完整地发布我的代码,正如回答者所要求的那样,我就不会找到这个解决方案。