Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Google Maps Server API key

Hi Everyone :) I am unable to get my google map to display correctly because it seems that the API is not recognized on my site. I added my hosted IP address to >my Google Developer Console in the Server key. I used the map-simple.html provided by Google and inserted my server key. I am having issues lol For some reason the whole map-simple.html is not showing in this window, but I am including the whole file on my site which includes

<"div id="map-canvas"></div">

<html> </head>

<script src="https://maps.googleapis.com/maps/api/js?key=MYKEY&sensor=false"></script>
<script>
    var map;
    function initialize() {
      var mapOptions = {
        zoom: 8,
        center: new google.maps.LatLng(-34.397, 150.644)
      };
      map = new google.maps.Map(document.getElementById('map-canvas'),
          mapOptions);
    }

    google.maps.event.addDomListener(window, 'load', initialize);
</script>

</head> <body> <div id="map-canvas"></div> </body> </html>

2 Answers

Try it without the key, i.e. remove key=%MYKEY%

In V.3 of the Maps API you do not need the key for JavaScript generated maps. You still do for static maps, however.

Hi Sean, Thanks for the response. I kept using my key. I was able to resolve the issue by going to my API Console and removing all referrers. This allowed all referers and allowed the maps to generate.

Thanks!!