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.

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

  2. Comment:You can create a CSV file containing a column name (called Placeholder) and add a second row with a placeholder string in the file. Save it with any name, such as Location.

  3. Open Spotfire and add the placeholder data table.

  4. Comment: You can add it to a visualization, such as the one you created to find a the distance from your location to any other data point on a map using TIBCO Spotfire for Apple iOS.

  5. 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.

  6. From the menu, click Insert > Calculated Column.

  7. 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.

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

  9. 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)

  10. 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 set 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 Spotfire for Apple iOS app.

  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. Select it, and then click Settings.

  6. In the Map 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.

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

  8. Scroll down to the box Limit data using expression, and click Edit.

  9. 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.
    Result: 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 image shows a map displaying zip code locations. The latitude and longitude are set to a location in Seattle, and isLocationSet is set to True.  The location layer displays a red triangle at the specified latitude and longitude.

 

map point showing current latitude and longitude

See also:

Location

Designing TIBCO Spotfire® Analytics for Small-Screen Display.