-1

I'm using GMaps to display a map on an html page but it gives this error on page

Oops! Something went wrong.

This page didn't load Google Maps correctly. See the JavaScript console for technical details.

And these errors in the console

EDIT: I've generated the API Key and added it to the URL and now I'm only getting this error

Uncaught TypeError: Cannot read property 'prototype' of undefined

I have also checked this thread: Google MAP API Uncaught TypeError: Cannot read property 'offsetWidth' of null

And tried the snippets posted there instead of my own, but I got the same errors.

This is my code

HTML

<div id="map_canvas" class="height-400 grayscale"></div>

JS and Includes

<script type="text/javascript" src="//maps.google.com/maps/api/js?key=AIzaSyDPN1LpoBuDzlvGox2qcREeDCnKu-hsGs4"></script>
<script type="text/javascript" src="assets/plugins/gmaps.js"></script>
<script type="text/javascript">

jQuery(document).ready(function(){

    /**
     @BASIC GOOGLE MAP
     **/
    var map2 = new GMaps({
        div: "#map_canvas",
        lat: -12.043333,
        lng: -77.028333,
        scrollwheel: false
    });

    var marker = map2.addMarker({
        lat: -12.043333,
        lng: -77.028333,
        title: "Company, Inc."
    });

});

</script>
Community
  • 1
  • 1
Halnex
  • 4,242
  • 12
  • 49
  • 102

1 Answers1

2

Try here to get an API key (Google account needed):

https://console.developers.google.com/apis/api/maps_backend/

For more information:

https://developers.google.com/maps/documentation/javascript/get-api-key

Toby
  • 12,743
  • 8
  • 43
  • 75
  • I generated the API and used it in the URL, but im still getting this error `Uncaught TypeError: Cannot read property 'prototype' of undefined` – Halnex Jul 19 '16 at 18:21
  • your code does not show the API key.. because the error is different, doesn't mean the previous problems are solved. Please update your code also. – Toby Jul 19 '16 at 18:29
  • I'm sorry, forgot the include it. Check it now. The API key is there. – Halnex Jul 19 '16 at 18:30
  • I'm assuming that you're following the examples correctly, that your `gmaps.js` file is linked correctly, etc. I'm not sure where the prototype error would originate from, but I would recommended viewing the source of this page, and using it as your starting point: https://hpneo.github.io/gmaps/examples/basic.html – Toby Jul 19 '16 at 18:33
  • I am using exactly that. The error is coming from `http://maps.google.com/maps-api-v3/api/js/25/8/common.js` – Halnex Jul 19 '16 at 18:35
  • Are you running this locally by dragging the file on to the browser? or on a web server? Can you link to your code? – Toby Jul 19 '16 at 18:43
  • I am running it locally inside XAMPP, I can provide you with the html code in a gist if you'd like. – Halnex Jul 19 '16 at 18:44
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/117742/discussion-between-halnex-and-toby). – Halnex Jul 19 '16 at 18:46