Link to home
Start Free TrialLog in
Avatar of FrankBabz
FrankBabz

asked on

Setting up web page to use google maps API javascript V3

Problem is Google is rejecting my API key.

I set up a web page and am using Google example for a map of Sidney Australia.

I have enabled use of javascript API V3 on Google website.

I am really lost where google setup is asking for valid IP addresses.  Must your Server have a static IP?  My workstation has a dynamic IP of 192.168.20.138 and my router gateway is 192.168.20.10.   I have tried many combinations of the above  - but no success.

I receive this pop-up window from Google advising "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........ etc."

I appreciate some/any suggestions....
Frank
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

I'm not sure why you doing it that way.  Here is one of the Google Maps demos that does not require an API key.
<!DOCTYPE html>
<html>
  <head>
    <title>Simple Map</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
			#contain{width:800px;height:600px;margin-left:auto;margin-right:auto;}
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
    <script>
var map;
function initialize() {
  var mapOptions = {
    zoom: 13,
    center: new google.maps.LatLng(-33.880, 151.211)
  };
  map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);
}

google.maps.event.addDomListener(window, 'load', initialize);

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

Open in new window

Avatar of FrankBabz
FrankBabz

ASKER

Hi Dave,

I very much appreciate, and will try, your suggestion.   I've chosen to do it the way I did because  what I was doing before was deprecated, and I found the new approach  while googling around on google sites for an alternative.

I now wonder if  your suggestion will be soon deprecated by google?   I presume google is trying to move everyone to the new model.   Any explanation, guidance or suggestions would be most appreciated?

Thanks again for your reply....  Frank
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the help.  

I've been upgrading from V2 but can't seem to get my "initialize" function to fire.  

Any clues would be appreciated.

Frank
It works in the version 3 demo page I posted.  You haven't shown me any code so I don't know what to tell you.
This may make no sense, but this statement is throwing the error perhaps???  due to a parameter problem or HTML5 issue...  

 src="https://maps.googleapis.com/maps/api/js?v=3.exp"

After the error all javascript loading stops.
Not on my machine or web server.  You can see it here:  http://www.dibsplace.info/SimpleMap.html  Copy the page I page posted above with no changes and run it on your server.