Set up Google Maps API
- UpdatedAug 1, 2024
- 5 minutes to read
- Xanadu
- Integrations
You enable the geolocation feature using the appropriate entries from a Google Maps API for Business license, or a Google Maps JavaScript API Key.
Before you begin
Role required: admin
About this task

Procedure
-
Google Maps APIs for Business licenses are no longer available
from Google, so, depending on whether have an existing license,
use one of the following procedures.
Note: You are required to use your own Google Maps JavaScript API Key from Google and not use any ServiceNow AI Platform® generated key.
Existing Google Maps API for Business license available? Tasks Existing license available - In the System Properties > Google Maps property form:
- In the google.maps.client
field,enter the Client ID for your organization. This ID
is from Google and starts with
gme-
, such asgme-mycompanyname
. - In the google.maps.private.key
field, enter the private key for Google
Maps API for Business. An example of an encoded key is
vNIXE0xscrmjlyV-12Nj_BvUPaw=
. The ServiceNow AI Platform® requires this key to retrieve accurate driving time estimates from Google for some Geolocation features. - Fill out the remaining values on the form.
- In the google.maps.client
field,enter the Client ID for your organization. This ID
is from Google and starts with
- Configure your maps using the property definitions from the table.
Note: See the Getting Started Guide on the Google website for details on obtaining a key, using the API, and relevant terms of service.No license available - Obtain a Google Maps JavaScript API Key from Google.
- In the System Properties > Google Maps property form, enter the API key into the
google.maps.key field.
Geolocation in the ServiceNow AI Platform® uses the API Key, which Google Maps also uses for Geolocation and map view billings.
- Fill out the remaining values on the form.
- Configure your maps using the property definitions from the table.
To learn more about Google Maps API for Business, and Google Maps JavaScript API Key, see https://developers.google.com/maps/gmp-get-started. - In the System Properties > Google Maps property form:
-
After you complete and save the configuration, create Map pages, or use the
default pages included with the plugin.
Map pages define what data appears on the map, and the appearance of the links. For a tutorial on how to view all of the markers that link to your records, see the Display Map Markers on Google Maps blog post on the ServiceNow Community.
Property Description google.maps.auto_close If true, automatically closes a map information window before opening a new one. - Type: true/false
- Default value: true
- Location: System Properties > Google Maps
google.maps.client Client ID for Google Maps API for Business. - Type: string
- Default value: gme-servicenow
- Location: System Properties > Google Maps
google.maps.private.key Private key for Google Maps API for Business. This key activates the geolocation feature, which locates users in the system precisely, using data from their mobile devices. - Type: string
- Default value: empty
- Location: System Properties > Google Maps
google.maps.version Version number of the current installation of Google Maps API for Business. - Type: string
- Default value: current version number
- Location: System Properties > Google Maps
google.maps.key Google Maps API for Business or Google Maps JavaScript API Key that ties to the URL of the server. This key authorizes development use of Google Maps API. - Type: string
- Default value: empty
- Location: System Properties > Google Maps
google.maps.latitude Starting latitude of the map. This value determines the starting position displayed in Google Maps. - Type: string
- Default value: 36.008522
- Location: System Properties > Google Maps
google.maps.longitude Starting longitude of the map. This value determines the starting position displayed in Google Maps pages. - Type: string
- Default value: -95.221764
- Location: System Properties > Google Maps
google.maps.max_items Maximum number of items to display on the map. - Type: integer
- Default value: 500
- Location: System Properties > Google Maps
google.maps.table Table used by the map. The table needs the following fields: name, longitude, latitude. - Type: string
- Default value: cmn_location
- Location: System Properties > Google Maps
google.maps.zoom Starting zoom level of the map (1 is the lowest) - Type: string
- Default value: 4
- Location: System Properties > Google Maps
-
Perform these configurations:
- Navigate to System Properties > All.
-
Set values for these system properties:
System property Description google.maps.refresh.latlong.duration Number of days after which the location details are updated. Note: The maximum value is 30.google.maps.refresh.latlong.record_count_per_table Maximum number of records in a table that can be processed using the scheduled job in one refresh. - Specify the tables that store the location details in the Map Coordinates Refresh Configuration [cmn_coordinate_refresh_config] table.
-
If there are no fields to track when the coordinates are last retrieved
in your tables:
- Create the coordinates_retrieved_on field of the type Date/Time in your tables.
- Ensure that the value of the field that tracks time when the coordinates are last retrieved, is populated correctly in the Map Coordinates Refresh Configuration [cmn_coordinate_refresh_config] table. Refer to the sample fix script Update coordinates updated on field to update values in the coordinates_retrieved_on field.
- Navigate to System Definition > Scheduled Jobs.
- Open the record, Refresh Latitude Longitude info of Records.
- Select the Active check box.
-
Specify the frequency at which the location details should be refreshed
by providing frequency details in Run and
Repeat Interval.
Note: Ensure that you refresh the location details at least once every 30 days.
- (Optional)
To access Google Maps from the ServiceNow
instance based on your region, perform these configurations.
- Navigate to User Administration > Users.
-
Select and assign the relevant Country Code for
the required user.
Note: If the required Country Code isn't available, add the dictionary entry. Ensure that you use the ISO 3166-1 country codes. For example, the country code of Morocco is MA.
- Navigate to System Properties > Google Maps.
- Select the Yes check box for Enable this property only when you want to alter the Google map's behavior based on a region. The region is populated from the current User's 'Country code' field value in sys_user record. The Country code value on the sys_user record should be consistent with the expectations from the Google Map's region code. Most Unicode region identifiers are identical to ISO 3166-1 codes, with some notable exceptions. Check the codes properly before making any changes.
- Click Save.