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

Chase Lester
Chase Lester
10,972 Points

Google Maps API Key disabled...?

So I have been going through putting google maps on a page with the Build an Interactive Website. Turned "on" Google Maps JavaScript API v3, went to API access and created a new browser key. I plugged that key in to my dynamic map and on my page I get this pop up...

"Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v3 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: https://developers.google.com/maps/documentation/javascript/tutorial#api_key"

I have followed the instructions and have gotten a key. Does it take a while to not have it disabled? Or does it need to be on a server first before google stops disabling it?

This is my code right now

        <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key={my_key_is_ here}&sensor=false"></script>
$('#map_here').prepend('<div id="map"></div>');
        $(".static_map").remove();

        function initialize() {
            var mapOptions = {
                center: new google.maps.LatLng(-34.397, 150.644),
                zoom: 8
            };
            var map = new google.maps.Map(document.getElementById("map"),
            mapOptions);
        }
        initialize();

I have also tried it with out the curly braces :

    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=my_key_is_here&sensor=false"></script>

5 Answers

Chase Lester
Chase Lester
10,972 Points

Alright... I figured it out. It was that referers part. I had to leave it blank and take away the curly braces. I initially thought it needed curly braces because of the code on googles page had curly braces. But now its working...

Axel Dekker
Axel Dekker
1,435 Points

Weird.. How long have you been waiting now?

Chase Lester
Chase Lester
10,972 Points

maybe a bit over an hour

Chase Lester
Chase Lester
10,972 Points

does it have anything to do with the Referers? I have it set to www.chaselester.com for now. And that is it. Is there a different thing I need to set it as? I am viewing the page offline but have also viewed it in a local server with the same issue.

Anyone any clue here?

Chase Lester
Chase Lester
10,972 Points

Sorry, new at this Google map thing.... For the referers, does it have to point to the exact page the map is used on, or just the website in general? I would guess the exact page, but I don't know really.