google distance Matrix api v3 showing error <p>I am trying to calculate the rates of the taxi fare from the distance of two locations using google distance matrix app.</p> <p>I created a new project, enabled the Google Maps Api V2 &amp; V3 from the services, copied the api key from Simple API Access</p> <pre><code>&lt;script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=MY_AppS_KeY&amp;sensor=false"&gt; &lt;/script&gt; </code></pre> <p>But I am getting errors like</p> <pre><code>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 v2 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: http://code.google.com/apis/maps/documentation/javascript /v2/introduction.html#Obtaining_Key </code></pre> <p>If i go back to my old apps key, i get following error:</p> <pre><code>This web site needs a different Google Maps API key. A new key can be generated at http://code.google.com/apis/maps/documentation/javascript /v2/introduction.html#Obtaining_Key. </code></pre> <p>Can any one Please Help</p> <p>The script i used is as follows:</p> <pre><code>&lt;?php $rate=20; $extra=0; ?&gt; &lt;head&gt; &lt;script type="text/javascript"src="http://maps.googleapis.com/maps/api /js?key=AIzaSyD0TzSohrtPSgWRQx8BhKryZKsjqQQH65Q&amp;sensor=true"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var geocoder, location1, location2, gDir; var map; var gdir; var geocoder = null; var addressMarker; var directionsPanel; var directions; function initialize() { geocoder = new GClientGeocoder(); gDir = new GDirections(); GEvent.addListener(gDir, "load", function() { var drivingDistanceMiles = gDir.getDistance().meters / 1609.344; var drivingDistanceround = Math.round(drivingDistanceMiles*100)/100; //if (40&gt;drivingDistanceMiles) //{ var cost = ((drivingDistanceMiles * &lt;?php echo $rate; ?&gt;) + (&lt;?php echo $extra; ?&gt;)) //} /*else { var cost = ((drivingDistanceMiles * &lt;?php echo $rate; ?&gt;) + (&lt;?php echo $extra; ?&gt;)) }; */ //var cost2 = cost + (cost * .0675); //var fare = Math.round(cost2*100)/100; var fare=cost; var fare = Math.round(fare*100)/100; document.getElementById('results').innerHTML = '&lt;table width="100%" style="border-collapse:collapse; padding-top:3px;"&gt;&lt;tr&gt;&lt;td rowspan="2" width="35"&gt;&lt;img src="images/rates.png"&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Distance: &lt;/strong&gt;' + drivingDistanceround + ' miles&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Estimated Cost: &lt;/strong&gt;$ ' + fare + '&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;'; }); if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(-33.722626, 150.810585), 10); gdir = new GDirections(map, document.getElementById("directions")); //directionsPanel = document.getElementById("route"); //directions = new GDirections(map, directionsPanel); //directions.load("from: "+ document.forms[0].from.value +" to: "+ document.forms[0].to.value+""); //directions.load("from: 500 Memorial Drive, Cambridge, MA to: 4 Yawkey Way, Boston, MA 02215 (Fenway Park)"); //directions.load("from: "+document.locations.to.value+" to: "+document.locations.to.value+""); GEvent.addListener(gdir, "load", onGDimrectionsLoad); GEvent.addListener(gdir, "error", handleErrors); } } function setDirections(fromAddress, toAddress, locale) { gdir.load("from: " + fromAddress + " to: " + toAddress); } function showLocation() { geocoder.getLocations(document.forms[0].from.value, function (response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode the first address"); } else { location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address}; geocoder.getLocations(document.forms[0].to.value, function (response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode the second address"); } else { location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address}; gDir.load('from: ' + location1.address + ' to: ' + location2.address); } }); } }); /////////////////////////////////////////////////////////// var directionsPanel; var directions; directionsPanel = document.getElementById("route"); directions = new GDirections(map, directionsPanel); directions.load("from: "+document.forms[0].from.value+" to: "+document.forms[0].to.value); } &lt;/script&gt; &lt;/head&gt; &lt;body onload="initialize()" onunload="GUnload()"&gt; &lt;table width="380px" border="2" cellpadding="0" cellspacing="0" bordercolor="#FF9F0F" style="border-collapse:collapse"&gt; &lt;tr&gt; &lt;td bgcolor="#FFFF99" style="padding:5px;"&gt;&lt;table width="375px" border="0" cellspacing="0" cellpadding="0"&gt; &lt;tr&gt; &lt;td&gt;&lt;div id="map_canvas" style="width: 374px; height: 255px; border: solid 1px #336699"&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;div id="form" style="width:374px; text-align:center; border: solid 1px #336699; background:#d1e1e4;"&gt; &lt;form action="#" onsubmit="document.getElementById('route').innerHTML=''; showLocation(); setDirections(this.from.value, this.to.value); return false;"&gt; &lt;p style="font-family:Tahoma; font-size:8pt;"&gt;From: &lt;input id="fromAddress" type="text" onblur="if(this.value=='') this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue) this.value='';" value="Street Name City, State" maxlength="50" size="26" name="from" style="font- family:Tahoma; font-size:8pt;" /&gt; To: &lt;input id="toAddress" type="text" onblur="if(this.value=='') this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue) this.value='';" value="Street Name City, State" maxlength="50" size="26" name="to" style="font- family:Tahoma; font-size:8pt;"/&gt; &lt;input class="submit" name="submit" type="submit" value="Calculate" style="font-family:Tahoma; font-size:8pt;" /&gt; &lt;/p&gt; &lt;div id="results" style="font-family:Tahoma; font-size:8pt; text-align:left; padding-left:5px; padding-bottom:5px;"&gt;&lt;/div&gt; &lt;div id="route" style="font-family:Tahoma; display:none; font-size:8pt; text-align:left; padding-left:5px; padding-bottom:5px;"&gt;&lt;/div&gt;&lt;a href="../large.php" target="_top" style="font-size:13px;"&gt;click here view large map with routes&lt;/a&gt; &lt;/form&gt; &lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; </code></pre>