API Properties¶
The API object's properties are listed in the sections below in alphabetical order.
currentHotspot¶
The currentHotspot
property returns an object containing properties for the current hotspot.
The current hotspot is the one whose content is showing. If the map uses popups, this function
returns the last hotspot that content was shown for. It returns null if no hotspot content has
been shown yet as would be the case when a map using popups first loads.
Example¶
let hotspotId = api.currentHotspot.id;
Hotspot Object Properties¶
- id
- The value of the Hotspot Id field on the Edit Hotspot Content screen.
- title
- The value of the Title field on the Edit Hotspot Content screen.
- htmlText
- The content from the Text field on the Edit Hotspot Content screen including HTML tags, or an empty string if there is no text content.
- plainText
- The content from the Text field on the Edit Hotspot Content screen excluding HTML tags. If the hotspot has no content, plainText is the hotspot’s tooltip text if it has a tooltip, otherwise, it’s an empty string.
- multimediaText
- The content from the Multimedia field on the Edit Hotspot Content screen or an empty string if there is no multimedia content.
- imageSrc
- The URL of the hotspot image on the Edit Hotspot Content screen or an empty string if there is no image.
currentPage¶
The currentPage
property returns a Page object containing properties for the map, gallery, or data sheet that the tour is currently displaying.
Example¶
let id = api.currentPage.id;
Page Object Properties¶
- id
- If the page is a map, the value comes from the Map Id field on the Advanced Map Options screen. If the page is a gallery, the value comes from the Gallery Id field on the Advanced Gallery Options screen. If the page is a data sheet, the value comes from the Data Sheet Id field on the Advanced Data Sheet Options screen.
- name
- The Map Name from the Map Setup screen.
- title
- The Map Title from the Advanced Map Options screen.
global¶
You can set and get the global
property to store and retrieve your own instance-specific data. The initial value of this property is an empty object {}
. You can assign properties to the object, or replace api.global
with your own object. It is not used by the API object. It is solely for use by your JavaScript to provide global access to data associated with an API instance.
Example¶
function onEventTourLoaded(event)
{
event.api.global.count = 0;
}
function onEventPageLoaded(event)
{
event.api.global.count += 1;
}
hotspots¶
The hotspots
property returns an array of Hotspot objects for each of the hotspots on the currently displayed map, gallery, or data sheet. A Hotspot object contains the same properties as the event.hotspot
object.
Example¶
let hotspots = api.hotspots;
for (const hotspot of hotspots)
console.log(hotspot.title);
instance¶
The instance
property returns the instance identifier for the API object's tour.
Example¶
if (api.instance === "usa")
return;
isSmallMobileDevice¶
The isSmallMobileDevice
property returns true or false to indicate whether the tour is running on a small mobile device. See the small-mobile
tour setting to learn how a tour determines whether a mobile device is small.
Example¶
function onEventTourLoaded(event) {
if (event.api.isSmallMobileDevice)
event.api.setMarkerHidden("MapTitle", true);
}
pages¶
The pages
property returns an array containing an element for each of the tour's maps, galleries, and data sheets. Each array element contains a single Page object containing the same properties as the event.page
object.
Example¶
let pages = api.pages;
for (const page of pages)
console.log(page.title);