- Details
- Parent Category: Coding
- Category: Maps JavaScript API
simplemap.html Simple Map (zoom 8 center: { lat: 52.759, lng: -1.709 } Barton Marina)
simplemap2.html Simple Map 2 (zoom 12 center: { lat: 52.534, lng: -1.828 } Lesley's)
code used
simplemap.html
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<link rel="stylesheet" type="text/css" href="/style.css" />
</head>
<body>
<div id="map"></div>
<!-- Async script executes immediately and must be after any DOM elements used in callback. -->
<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDiB6PpwXGX9hUmIqddIq2Do2c4p0BIrG0&callback=initMap&v=weekly"
async
></script>
<script src="/script.js"></script>
</body>
</html>
style.css
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
script.js
let map;
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: { lat: 52.759, lng: -1.709 },
zoom: 8,
});
}
higher the zoom number the more the zoom