TIBCO Cloud™ Spotfire® Web Client User Guide

Finding your location on a map using the Spotfire app

You can add a marker showing the current latitude and longitude in a map visualization, identifying where iOS mobile app users are currently located when they tap the location icon in the app.

Before you begin

Before you complete these tasks, you might want to work through the tasks in Adding location capabilities to an analysis.

About this task

Adding expressions to find your location

To show a marker with your current location, you must first create a new data table, containing three calculated columns based on the location properties.

Procedure

  1. Create a single-column data table that contains a name row and one placeholder data row using Notepad or Excel.
    Tip: You can create a CSV file containing a column name (for example 'Location') and add a second row with a placeholder string (for example 'My location') in the file. Save it with any name; in this example we use 'Location'.
  2. Open Spotfire and add the placeholder data table.
    You can add it to an already existing analysis, such as the one described in Adding location capabilities to an analysis.
  3. If they do not already exist, add two document properties: AppGeoLatitude and AppGeoLongitude, as described in the section Adding the location properties in Adding location capabilities to an analysis.
  4. From the menu bar, select Data > Add calculated column.
  5. In the resulting dialog, make sure you have selected the new 'Location' data table, add the expression ${AppGeoLatitude}, and in the Column name field, provide a name such as 'lat' . Click OK to save the change.
  6. Create another calculated column in the 'Location' data table by adding the expression ${AppGeoLongitude}, and providing another name, such as 'long'. Save the change.
  7. Create another calculated column in the 'Location' data table, using the following Expression:
    Not(${AppGeoLatitude}=0.0 and ${AppGeoLongitude}=0.0)
    The data type of this expression should be Boolean by default, with the value of True (unless you have used a mobile app to change the current latitude and longitude to something other than 0.0/0.0). This expression determines whether the two document properties (AppGeoLatitude and AppGeoLongitude) are set to 0 and 0, which is the intersection of the equator and the prime meridian. If they are not set to 0 and 0, then a marker is added to the map at the point where the latitude and longitude values intersect. (If the values are 0 and 0, then no marker is shown.)
  8. In the Column name field, give the new column a name such as 'isLocationSet'.

Results

You now have a data table with three calculated columns that you can use to mark your current location in a map chart visualization designed for the mobile Spotfire app.

Adding a marker to show your current location

When you have created the data table containing your current location as described above, you can add this data table as a marker layer in a map chart visualization.

Before you begin

These steps must be authored in the installed client.

Procedure

  1. Create a new map chart, or use the one you created in Adding location capabilities to an analysis.
  2. Right-click the map chart, and select Properties.
  3. In the map chart properties, select Layers.
  4. Click Add > Marker Layer, and add the 'Location' data table.
  5. In the marker layer settings for Location, select Colors, and change the color for All values to a color that stands out. For example, if your data points are all blue, you could make the location color red.
  6. Optionally, click Shape, and select a shape to distinguish the marker, such as an X or a star.
  7. Locate the Data section of the Marker Layer Settings, and, under Data limiting, add a limitation based on an Expression (also known as Limit data using expression).
  8. In the Limit Data Using Expression dialog, select the column isLocationSet, and then click Insert Columns. Click Close to close and save the change.
    The column is added as an expression. When the value of isLocationSet is set to False, the marker in the location map layer is hidden.

Results

In the map, if the value of latitude and longitude both are not 0, and if the isLocationSet is True, the marker of the specified shape and color is shown on the map at the current latitude and longitude.
This example shows bike rental stations in the Swedish city Gothenburg. The text area at the top shows the current location as Latitude and Longitude. The column isLocationSet is set to True, which means that the Location marker layer displays a red marker at the current latitude and longitude.