Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use google maps without api key

Hi i am using this code to use get-directions in google maps. but when i run this from other machines it is showing the error invalid api key. how to use this same map without an api key.

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAuPsJpk3MBtDpJ4G8cqBnjRRaGTYH6UMl8mADNa0YKuWNNa8VNxQCzVBXTx2DYyXGsTOxpWhvIG7Djw" type="text/javascript"></script>     <style type="text/css">     body {       background:#FFE1C7;       font-family: Verdana, Arial, sans serif;       font-size: 11px;       margin: 2px;     } table.directions th {       background-color:#EEEEEE;     }      img {       color: #000000;     }     </style>     <script type="text/javascript">      var map;     var gdir;     var geocoder = null;     var addressMarker;      function initialize() {       if (GBrowserIsCompatible()) {               map = new GMap2(document.getElementById("map_canvas"));         gdir = new GDirections(map, document.getElementById("directions"));         GEvent.addListener(gdir, "load", onGDirectionsLoad);         GEvent.addListener(gdir, "error", handleErrors);          setDirections("Bangalore", "Mysore", "en_US");       }     }      function setDirections(fromAddress, toAddress, locale) {       gdir.load("from: " + fromAddress + " to: " + toAddress,                 { "locale": locale });     }      function handleErrors(){      if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)        alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);      else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)        alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);       else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)        alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);      //   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong     //     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);       else if (gdir.getStatus().code == G_GEO_BAD_KEY)        alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);       else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)        alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);       else alert("An unknown error occurred.");     }      function onGDirectionsLoad(){         // Use this function to access information about the latest load()         // results.          // e.g.         // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;       // and yada yada yada...     }      </script> 

Can anyone help me...thanks in advance..

like image 990
Mud Hut Avatar asked Sep 27 '12 06:09

Mud Hut


People also ask

Can we use Google Map without API key?

In order to embed a Google Map iframe without api key add a Google Map widget from the left side panel. Then open it and add the address. This way you can embed Google Map without api key via Elementor.

Is Google Maps API still free?

You won't be charged until your usage exceeds $200 in a month. Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).

How are API keys necessary for Google Maps?

The API key is a unique identifier that authenticates requests associated with your project for usage and billing purposes. You must have at least one API key associated with your project. If playback doesn't begin shortly, try restarting your device.

Can I get Google Maps API key without billing?

It is still possible to enable Maps API without billing, but it has to be done through the Cloud SDK console.


1 Answers

Note : This answer is now out-of-date. You are now required to have an API key to use google maps. Read More


you need to change your API from V2 to V3, Since Google Map Version 3 don't required API Key

Check this out..

write your script as

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
like image 100
Usman Avatar answered Sep 24 '22 06:09

Usman