What are layers?

In the context of creating and using markers in XP360, a layer is a group of markers. Adding markers to different layers allows you to better manage those markers as part of a group instead of modifying each marker individually. An example would be adding markers for restaurants to a layer named “food”, and markers for hotels to a layer named “hotels”. You can then interact with and modify the markers in the “food” layer without the “hotel” markers being changed.

What can they be used for?

Here are a few examples of what layers can be used for:

How to add/change layers?

There are two easy ways to add a layer, and one way that can be used if the first two ways can’t be used. The three methods to add a layer are as follows:

Method 1) When adding a marker, there is a “layer” parameter that can be used to add the marker to a specific layer (using the layer name). If this isn’t set when making the marker, it will be added to a layer named “default”. If you attempt to add a marker to a layer that doesn’t exist yet, a new one will be created with the name you specify.

Method 2) When constructing your AerialSphere object, there is a parameter called sphereData which takes an object that specifies all the settings for the created aerialSphere object. sphereData has an array named “layers” which is where all the layer information is created (and stored for future use). When creating your sphereData object (as part of AerialSphere object creation), you can use a specified “layers” array consisting of one or more objects with the following information (this will create all layers from the start):

Method 3) This method should only be used if the previous two methods can’t be used, which usually happens when you need to add a layer after the AerialSphere object has been created, and all markers have already been added. Just as you can create an array of “layer” objects when creating sphereData, you can create a new array of “layer” objects and overwrite what is in sphereData with the new array. Keep in mind that overwriting this way will get rid of all previous layers (and any markers added to those layers), so it is a good idea to first grab the array of layers and add/change from there to ensure no data is lost. 

Functions to work with layers

There are two main functions you will use when working with layers: getLayer() and setLayerVisibility()