Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to add a simple google map to a project I am working on, I used the documentation instruction step by step on developers.google.com/maps. I get an error which says .

index.html:1 Uncaught (in promise) pe {message: 'initMap is not a function', name: 'InvalidValueError', stack: 'Error\n    at new pe (https://maps.googleapis.com/mAPIkey&&callback=initMap:193:124'}


JavaScript
function initMap() {
  // The location of Uluru
  const ph = { lat:4.8472, lng:6.9746 };
  // The map, centered at Uluru
  const map = new google.maps.Map(document.getElementsByClassName("map"), {
    zoom: 4,
    center: ph,
  });
  // The marker, positioned at Uluru
  const marker = new google.maps.Marker({
    position: ph,
    map: map,
  });
}


the error message read initMap is not a function while it's actually a function you van take a look at the JVS code.

What I have tried:

I added this script tag to the bottom of my HTML

<script
    src="https://maps.googleapis.com/maps/api/js?key=APIKey&callback=initMap">
</script>
Posted
Comments
RedDk 8-Mar-22 14:06pm    
Well, you could start by replacing variable names. Just to see whether the SAME error comes back. Checking for error, a kind of fail-safe (do until it breaks), might determine whether there's spoof. Or something.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900