javascript - initMap is not a function - map not rendering. Google Maps API - JS -
i experiencing known issue initmap not function
, don't see how solve it. i've tried various methods recommended in other questions none of them work. plausible solution found involving usage of angularjs trying accomplish script without it.
here html code:
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=xxxxxx&callback=initmap"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-tc5iqib027qvyjsmfhjomalkfuwvxzxupncja7l2mcwnipg9mgcd8wgnicpd7txa" crossorigin="anonymous"></script> <script src ="script.js" /> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-bvyiisifek1dgmjrakycuhahrg32omucww7on3rydg4va+pmstsz/k68vbdejh4u" crossorigin="anonymous"> <link rel="stylesheet" href ="style.css"> </head> <body> <div id ="map-canvas"> </div> </body> </html>
js code:
window.initmap = function() { var uluru = {lat: -25.363, lng: 131.044}; var map = new google.maps.map(document.getelementbyid('map-canvas'), { zoom: 4, center: uluru }); var marker = new google.maps.marker({ position: uluru, map: map }); };
for js code, literally copied , pasted what's in google's documentation small change made here window.initmap = function()
.
things i've tried:
- changing
function initmap()
window.initmap = function()
- delete in
initmap()
, givingalert("ok")
see if come up. well, didn't. - changed position of
async defer
end of script reference, put script reference @ top.
questions i've checked in detail:
first try, second, third time wasn't charm
the error message :
my map not being rendered , keep getting error, ideas how fix it?
two issues:
- add missing
</script>
tag - change order of page load:
<div id="map-canvas"> </div> <script src="script.js" defer async></script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=xxxxxx&callback=initmap"></script>
Comments
Post a Comment