Search code examples
javascriptdreamweaver

Google Maps Auth. Key - where to put it?


I am a complete noob when it gets to building webpages but I am willing to learn. I obtained a template website (Urbanic Template - http://www.templatemo.com/tm-395-urbanic) and am trying to make (In Dreamweaver CS6) Google maps work. I did all the usuall (registered,opened the account..) and obtained the key to put in my webpage but dont know where and how. In my templatemo_script.js I can see the reference to the default cordinates of the map.

function initialize() {
    var mapOptions = {
        zoom: 12,
       center: new google.maps.LatLng(16.8451789,96.1439764)
     };

     var map = new google.maps.Map(document.getElementById('map-canvas'),  mapOptions); }

So where and how am I exactly to put in the obtained Google Key so my site functions as it should ? Coordinates I will change ofcourse.


Solution

  • You need to insert it where you are loading the library. As user Phil pointed out, the documentation shows that it should be included in the script tag when loading the google maps library.

    <script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
      type="text/javascript"></script>
    

    If you aren't sure where this is, you may want to consider starting back at the basics of web development, just so you can get a solid understanding of the structure of a webpage.

    But for starters, you might try looking in the index.html.