Я пытаюсь интегрировать карты Google с моим примером веб-приложения, используя Bootstrap 4, и карты Google не отображаются. Я проверяю элемент и вижу, что свойство переполнено: скрыто, и когда я удаляю свойство, оно показывает карту за пределами холста браузера, но не могу выяснить проблему и исправить ее.
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="main.css" rel="stylesheet">
<link href="css/all.css" rel="stylesheet"> <!--load all styles -->
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Vibur&display=swap" rel="stylesheet">
<title>Chicken King</title>
</head>
<body>
<div class="container-fluid">
<div class="row text-center">
<div class="col-md-12 text-center">
<h1 id="logo">Chicken King</h1>
</div>
</div>
<div class="row">
<div id="demo" class="carousel slide" data-ride="carousel">
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
<li data-target="#demo" data-slide-to="1"></li>
<li data-target="#demo" data-slide-to="2"></li>
</ul>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="slide1.jpg" alt="Los Angeles" width="1100" height="500">
<div class="carousel-caption">
<h3>The Classic Sandwhich</h3>
<p>Your tastebuds will love this thing!</p>
</div>
</div>
<div class="carousel-item">
<img src="slide2.jpg" alt="Chicago" width="1100" height="500">
<div class="carousel-caption">
<h3>Crispy</h3>
<p>You will love how we deep fry it!</p>
</div>
</div>
<div class="carousel-item">
<img src="slide3.jpg" alt="New York" width="1100" height="500">
<div class="carousel-caption">
<h3>Ohh Fancy...</h3>
<p>Come try our new BBQ Chicken</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
</div>
<div class="row" id="chickenTopRow">
<div class="col-sm-4 offset-sm-1">
<img src="box1.jpg" class="img-fluid">
<h1 class="textOnImage">100% Fresh</h1>
</div>
<div class="col-sm-4 offset-sm-2">
<img src="box4.jpg" class="img-fluid">
<h1 class="textOnImage">Hand Made</h1>
</div>
</div>
<div class="row" id="chickenBottomRow">
<div class="col-sm-4 offset-sm-1">
<img src="box3.jpg" class="img-fluid">
<h1 class="textOnImage">All Natural</h1>
</div>
<div class="col-sm-4 offset-sm-2">
<img src="box2.jpg" class="img-fluid">
<h1 class="textOnImage">Tasty</h1>
</div>
</div>
<div class="row text-center">
<h1 class="phoneColumn"><i class="fas fa-phone-volume fa-1x"></i>
Order Now <i class="fas fa-phone-volume fa-1x"></i></h1>
<br>
<h1 class="phoneColumn">281-330-8400</h1>
</div>
<div class="row" id="#mapRow">
<div id="map"></div>
</div>
</div>
<script>
// Initialize and add the map
function initMap() {
// The location of Uluru
var uluru = {lat: -25.344, lng: 131.036};
// The map, centered at Uluru
var map = new google.maps.Map(
document.getElementById('map'), {zoom: 4, center: uluru});
// The marker, positioned at Uluru
var marker = new google.maps.Marker({position: uluru, map: map});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY&callback=initMap">
</script>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>
Вот код моего CSS
#logo{
font-family: 'Vibur', cursive;
}
.carousel-item img {
width: 100vw;
height: 100%;
}
.textOnImage{
position: absolute;
width: 100%;
text-align: center;
top: 50%;
color: white;
}
#chickenTopRow{
padding-top: 20px !important;
padding-bottom: 20px !important;
}
#chickenBottomRow{
padding-bottom: 20px;
}
.phoneColumn{
display: block;
width: 100%;
}
#map{
height: 400px;
}
Я только что проверил и изменил ширину #map div на 100% в таблице стилей, и это устранило проблему. Это был метод проб и ошибок, и я до сих пор не могу понять проблему.
Может ли кто-нибудь мне помочь?
Спасибо,