Scripting for map pages
-
- UpdatedJan 30, 2025
- 5 minutes to read
- Yokohama
- Navigation and UI
The Script field on the Map Page form allows the use of attributes or custom code to define map characteristics, such as marker appearance, display information, and more.
Scripting map item attributes
The following attributes are available.Scripting custom map page behavior for smartphone
If you plan to access the map page from a smartphone, you may want to set custom smartphone interface behavior using the isMobile variable. You can use the isMobile variable to set custom behavior for the smartphone view of the map. For example, you might set different values for the icon_width and icon_height attributes when isMobile is true.Basic map page script
isMobile map page script
Advanced map page script
This script displays the number of open incidents by location. It varies the size of the icon based on the number of open incidents for the location. Using the html parameter, it also displays the location name and number of incidents, as well as a link to the list of related incidents.Map page marker label script
Marker labels allow you to add dynamic text to markers. This example displays the active incident count at each location.
On this page
Related Content
- Set up Google Maps API
You enable the geolocation feature using the appropriate entries from a Google Maps API for Business license, or a Google Maps JavaScript API Key.
- Create a map page
Your ServiceNow instance provides several default map pages. You can also create custom map pages with the script examples described in this page.
- Create a map page module
You can create a new application module for desktop or smartphone users to display a Google map page.
- Create an advanced Map Page
Use advanced configuration to set up Map Pages without scripting.
- Set map application scope
Enable map application scope to specify which application can modify your Map Page configuration.
- Create a smartphone map page module
You can create a custom smartphone module that links directly to a map page.