Finding Your Location on a Map Using the Spotfire App


This task adds a marker to the latitude and longitude to a map visualization, identifying where a mobile app user is currently located when the user taps the location icon in the app. Before you complete this task, you might want to work through the tasks in Adding Location Capabilities to a Map Visualization.

Adding expressions to find your location:

  1. Create a single-column data table that contains a name row and one placeholder data row.

    Comment: 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, such as Location.

  2. Open Spotfire and add the placeholder data table.

    Comment: You can add it to a visualization, such as the one described in Adding Location Capabilities to a Map Visualization.

  3. If they do not already exist, add two document properties: AppGeoLatitude and AppGeoLongitude, as described in the section To add location capabilities for your mobile users.

  4. From the menu bar, select Data > Add calculated column.

  5. In the resulting dialog, double-click the property AppGeoLatitude to insert it in an expression, and then in the Column Name box, provide a name, such as lat. Save the change.

  6. Create another calculated column, double-clicking the property AppGeoLongitude, and in the Column Name box, provide another name such as long. Save the change.

  7. Create another calculated column, and in the Expression text box, type the following expression. In the Column Name box, give it a name such as isLocationSet.
    Not(${AppGeoLatitude} = 0.0 and ${AppGeoLongitude} =0.0)

    Comment: This expression data type should be set to boolean automatically, with the default value of True. 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.)

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

Adding a marker to show your current location:

  1. Create a map visualization, or use the visualization you created in  Adding Location Capabilities to a Map Visualization.

  2. Right-click the map, and in the menu click Properties.

  3. In the Map Chart Properties dialog, select Layers.

  4. Click Add > Marker Layer, and add the Location data table to your layers.

  5. In the Marker Layer Settings dialog, select Colors, and set the color so the location value stands out. For example, if your data points are all set to blue, you could set it to red.

  6. Optionally, click Shape, and select a shape to distinguish the marker, such as an X or a star.

  7. Go to the Data page of the Marker Layer Settings, and scroll down to the box Limit data using expression, then click Edit.

  8. In the Limit Data Using Expression dialog, select the column isLocationSet, and then click Insert Columns. Click OK to close and save the change, and then close the Settings and Properties dialogs.

  9. Response: The column name is added as an expression. When the value of isLocationSet is set to False, the marker in the location map layer does not appear.

In the map, if the value of latitude and longitude both are not 0, and if the isLocationSet is True, the specified shape and color marker appears on the map at the specified 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.

map point showing current latitude and longitude

See also:

Location

Designing TIBCO Spotfire® Analytics for Small-Screen Display.