I would like to use the Google Maps JavaScript API to display a map in my html View. I'm building a ASP.NET MVC web application. I have included the reference script, the initmap() function and the map div element. I'm getting an error that says 'initMap' is not a function in the console.Here's the code:
<script defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCKLXdTfjmz8GlKELpyrmDxCgkkmAiy23c&callback=initMap">
</script>
<div id="map"></div>
<script>
$(document).ready(function () {
});
function initMap() {
var uluru = {lat: -25.363, lng: 131.044};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: uluru
});
var marker = new google.maps.Marker({
position: uluru,
map: map
});
console.log("Map initialized");
}
</script>
EDIT: I moved the initMap() function outside $(document)ready() and there were no errors. But the Map still doesn't show up on the screen.