Skip to content

Instantly share code, notes, and snippets.

@TravelTime-Frontend
Last active February 21, 2023 08:24
Show Gist options
  • Save TravelTime-Frontend/66ae176dc08f3804f8d2191b3dc8582f to your computer and use it in GitHub Desktop.
Save TravelTime-Frontend/66ae176dc08f3804f8d2191b3dc8582f to your computer and use it in GitHub Desktop.
Google Maps JavaScript API initial setup
<html>
<head>
<style>
body {
background-color: gray;
}
html,
body,
#map {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id='map'></div>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY_GOES_HERE&callback=initMap" async
defer></script>
<script>
var map;
function initMap() {
var mapOpts = {
center: { lat: 51.5031653, lng: -0.1123051 },
zoom: 13,
};
map = new google.maps.Map(document.getElementById('map'), mapOpts);
var marker0 = new google.maps.Marker({
position: { lat: 51.5031653, lng: -0.1123051 },
map: map,
title: 'London Waterloo train station',
animation: google.maps.Animation.DROP
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment