Google API Key
The Google API Key is required for the identification of the browser application. Google counts all instances of access to the API and blocks access once the API is accessed a certain number of times. The access count is 25,000/day. (as of September 2013). Additional accesses can be purchased via the website <a href="https://code.google.com/apis/console"></a>. However, this is only necessary if the corresponding application has exceeded the 25,000 limit for 90 days in succession.
Creating the Google API Key
Follow the following steps to create a Google API Key:
- Visit the Google website at <a href="https://code.google.com/apis/console"></a> and log in with your Google account.
- Click on the Services link in the menu on the left hand side.
- Activate the Google Maps API v3 service.
- Click on the API Access link in the menu on the left. your API key is available on the API Access page in the Simple API Access section. Google Maps API applications use the key for the identification of browser apps.
- (optional) By default, a key can be used on all websites. We highly recommend that you limit the use of your key to domains that you administer, in order to avoid the use of unauthorized websites. You can specify which domains your API key can use. To do so, in the APIs console click on the Edit allowed referrers link for your key.
Further information on the creation of a Google API Key can be found via the following link <a href="https://developers.google.com/maps/documentation/javascript/tutorial?hl=de#api_key"></a>.
Using a Google API Key
Example: Google API use without a key
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
Example: Google API use without a key, but with "Places Library"
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&libraries=places"></script>
Example: Google API use with a key and with "Places Library"
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyB8PYh2EdHLwgYdkW5UO54zDClATrnlRMU&sensor=false&libraries=places"></script>
Notes:
- "Use of the Google Maps API requires that you indicate whether your application is using a sensor (such as a GPS locator) to determine the user's location.
This is especially important for mobile devices. Applications must pass a required sensor parameter to the <script>-tag when including the Maps API javascript code, indicating whether or not your application is using a sensor device.
Applications that determine the user's location via a sensor must pass sensor=true when loading the Maps API JavaScript. Note that even if your device does not use a sensing device, you must still pass this parameter, setting its value to false." (Source: Google <a href="https://developers.google.com/maps/documentation/javascript/tutorial?hl=de#api_key"></a>) - Because Google sends a somewhat different response for mobile devices than compared with non-mobile devices, the "sensor= <boolean>" parameter must be specified when calling up the Google Maps Library.
- For the integration of Google Maps within Umantis, the "sensor = false" parameter can be specified in almost all cases.
- If the solution exchanges data via a secure connection (https://) the calling up of external Javascript libraries with https:// can also be added. If the advertisement layout has been tested locally, http:// must be used for the loading of the script.
Error causes
Error Alert Box
If an Error Alert Box appears, the following may have occurred:
- The URL does not comply with the approved URLS entered in the Google API Console for this key
- The API Key was not entered correctly
Solution:
- Add the URL to the list of approved URLs (see: <a href="https://code.google.com/apis/console"></a>)
- Check whether all "&" and "?" have transferred across correctly. There can only be one "?" and no "{}" in the URL. In addition, it may be the case that the "&" must be 'escaped' with "&" or vice versa.
Further information
- Further information on the creation and use of the Google API Key can be found via the following link <a href="https://developers.google.com/maps/documentation/javascript/tutorial?hl=de"></a>.