Maps JavaScript API URL Parameters

This document discusses all of the parameters you can specify in the query string of the script loading URL when loading the Maps JavaScript API. Certain parameters are required while others are optional. As is standard in URLs, all parameters are separated using the ampersand (&) character.

The following example URL has placeholders for all possible parameters:

https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY
&callback=FUNCTION_NAME
&v=VERSION
&libraries="LIBRARIES"
&language="LANGUAGE"
&region="REGION"
&solution_channel="SOLUTION_IDENTIFIER"
&auth_referrer_policy="AUTH_REFERRER_POLICY"

The URL in the following example script tag loads the Maps JavaScript API:

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

Required parameters

The following parameters are required when loading the Maps JavaScript API.

  • key: Your API key. The Maps JavaScript API will not load unless a valid API key is specified.

  • callback: The name of a global function to be called once the Maps JavaScript API loads completely.

Optional parameters

Use these parameters to request a specific version of the Maps JavaScript API, load additional libraries, localize your map or specify the HTTP referrer check policy

  • v: The version of the Maps JavaScript API to use.

  • libraries: A comma-separated list of additional Maps JavaScript API libraries to load.

  • language: The language to use. This affects the names of controls, copyright notices, driving directions, and control labels, as well as the responses to service requests. See the list of supported languages.

  • region: The region code to use. This alters the map's behavior based on a given country or territory.

  • solution_channel: Google Maps Platform provides many types of sample code to help you get up and running quickly. To track adoption of our more complex code samples and improve solution quality, Google includes the solution_channel query parameter in API calls in our sample code.

  • auth_referrer_policy: Maps JS customers can configure HTTP Referrer Restrictions in the Cloud Console to limit which URLs are allowed to use a particular API Key. By default, these restrictions can be configured to allow only certain paths to use an API Key. If any URL on the same domain or origin may use the API Key, you can set auth_referrer_policy=origin to limit the amount of data sent when authorizing requests from the Maps JavaScript API. This is available starting in version 3.46. When this parameter is specified and HTTP Referrer Restrictions are enabled on Cloud Console, Maps JavaScript API will only be able to load if there is an HTTP Referrer Restriction that matches the current website's domain without a path specified.