This time, i'll go right to the point:
HTML:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="code.js"></script>
</head>
<body>
<div id="map"></div>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=*snip*&callback=initMap">
</script>
</body>
</html>
Code.js:
$(document).ready(function () {
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {
lat: -34.397,
lng: 150.644
},
zoom: 10
});
}
});
Result:
Uncaught TypeError: window.initMap is not a function.
Tips?
Also, wonder if this part:
<script async defer src="https://maps.googleapis.com/maps/api/js?key=*snip*&callback=initMap">
Can be moved to the same code.js file.