Reputation: 61
I have been trying to display a marker on the map when I click an address but the map is not displayed.
<div class="gmap_canvas">
<div id="g-map"></div>
</div>
<script src="https://maps.googleapis.com/maps/api/js?key=app_key&callback=initialize" async defer></script>
function initialize() {
var latlog = new google.maps.LatLng(39.305, -76.617);
var map = new google.maps.Map(
document.getElementById('g-map'), {
zoom: 4,
center: latlog
}
);
// The marker, positioned at map
var marker = new google.maps.Marker({
position: latlog,
map: map
});
}
Upvotes: 0
Views: 44
Reputation: 849
You should add style="width:100%; height:100%;
to the gmap_canvas div.
<body>
<div style="height:100%; width: 100%;">
<div id="map-canvas"></div>
</div>
</body>
Upvotes: 1