Search code examples
javascriptgoogle-mapsgoogle-maps-api-3requirejs

How to check if Google maps API key is integrated


Question:- Is there any way to check that whether google maps has been integrated with correct api key?

Description:- I am using Google maps in my project which was not developed from scratch by me. The project has also used async loading of maps using requirejs as well. But I am not sure whether the key entered in the code is valid or not or it is integrated correctly as the code does not have the key param on the query string. So I am not sure whether the key is integrated correctly or we are just using the free network calls for google maps. Here is the code which is being used. Moreover the project has also used require js as well.

define('google', ['async!//maps.google.com/maps/api/js?MAPS_API_KEY&v=3.17&libraries=places,geometry'],
function(){dependencies
    return window.google;
});

As you can see that the code does uses "key" parameter in the quesry string So I am not sure whether key is integrated or not.

As most of us read in the documentation of google maps to add the key param in the

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

My only concern is this "key" param required to be passed or not.

Any help or suggestions will be appreciated.


Solution

  • The API key is required and it must be present in the request. The keyless access was deprecated in June 2016 and here is the blog post that announced the mandatory API keys:

    https://maps-apis.googleblog.com/2016/06/building-for-scale-updates-to-google.html

    Particularly it contains the following statement:

    We no longer support keyless access (any request that doesn't include an API key). Future product updates are only available for requests made with an API key. API keys allow us to contact developers when required and help us identify misbehaving implementations.

    In order to check if your site implements correctly Google Maps JavaScript API you can use the Google Maps API Checker Chrome extension:

    https://chrome.google.com/webstore/detail/google-maps-api-checker/mlikepnkghhlnkgeejmlkfeheihlehne?utm_source=chrome-app-launcher-info-dialog

    I hope this information is helpful.