Adding Location Capabilities to a Map Visualization


If your data has latitude and longitude columns, you can create a visualization that a mobile device user can access to determine the distance from a location. Just add reserved document properties and a calculated column for distance calculation, and then share your visualization with mobile users. The document properties activate the location icon in the mobile device. The following example demonstrates how to create such a visualization and test it.

To add location capabilities for your mobile users:

  1. Open a file containing the data with latitude and longitude columns.

    Comment: Check the Import Settings to make sure the column names and data types are correct.

  2. In the Data in analysis flyout, select the latitude and longitude columns.

  3. Add the map chart that is recommended.

  4. Comment: You can apply any Color by settings, map layers, or filters at any time.

  5. On the menu bar, select File > Document properties, and in the Document Properties dialog, click the Properties tab.

  6. Click New, and in the resulting dialog, provide the reserved name AppGeoLatitude.

  7. Set the Data Type to Real, and the Default Value to 0.0 (the equator).

  8. Comment: For testing purposes, you can set AppGeoLatitude to  your latitude, but before saving the final version, set it to 0.0.

  9. Add another document property, providing the reserved name AppGeoLongitude, setting the Data Type to Real and setting the Default Value to 0.0 (the prime meridian).

  10. Comment: For testing purposes, you can set AppGeoLongitude to your longitude, but before saving the final version, set it to 0.0.

Your visualization now has the document properties required to activate the location icon on a mobile device that can open it (available for a consumer user, either on TIBCO Cloud Spotfire or on premises).

To add distance calculation capabilities for your mobile users:

  1. On the menu bar, select Data > Add calculated column.

  2. In the Expression field, build the following expression:
    6371000 * GreatCircleDistance(${AppGeoLatitude}, ${AppGeoLongitude}, [latitude], [longitude])

    Comment: This calculation specifies meters. To specify miles, use 3959. To specify kilometers, use 6371.

    Comment: latitude and longitude in this example reflect column names. If yours differ, modify the example.

  3. Give the column a name, such as distance, and click OK to save and close the dialog.

    Response: The calculated column is shown in the Data in analysis flyout.

Your visualization now has a column that you can use to measure distances between the iOS device and any data point in the data table by using its geo-positioning properties.

To add visualizations for app users to see location and distances:

  1. On the authoring bar, click    to open the Visualization types flyout.

  2. Drag the Text area to the wanted position on the analysis page.

    Response: A blank text area is created.

  3. Right-click the new text area, and then click Properties.

  4. In the dialog, provide a title, such as 'Your Location'. Close the dialog to save the change.

  5. Click the Edit icon to edit the text area, and insert two property controls, one for the document property AppGeoLatitude and one for AppGeoLongitude, and provide text labels. Save the changes.

  6. Resize the text area to contain just these two controls and the title.

  7. Right-click the map visualization, and from the menu, select Create Details Visualization > Table.

  8. Right-click the table visualization, and then click Properties.

  9. Provide a name for the visualization, such as 'Distance from Your Location'. Close the dialog to save the change.

  10. Test the visualization by selecting a data point or a range of data points on the map.

    Response: The Details Visualization shows the selected data rows, with the calculated column reflecting the distance from the latitude and longitude shown in 'Your Location'.

  11. Save the analysis and share with your mobile users.

This example shows bike rental stations in a Swedish city. Each rental station has a location specified by latitude and longitude. You can see the distance (measured in metres) from your current location to the three rental stations that are marked in the map chart.

See also:

Location

Finding Your Location on a Map using the Spotfire App

Designing Spotfire® Analytics for Small-Screen Display.