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:
Create a single-column data set that contains a name row and one placeholder data row.
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.
Open Spotfire and add the placeholder data table.
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.
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.
From the menu, click Insert > Calculated Column.
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.
Create another calculated column, double-clicking the property AppGeoLongitude, and in the Column Name box, provide another name such as long. Save the change.
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 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.
Adding a marker to show your current location:
Create a map visualization, or use the visualization you created in Adding Location Capabilities to a Map Visualization.
Right-click the map, and in the menu click Properties.
In the Map Chart Properties dialog, select Layers.
Click Add > Marker Layer, and add the Location data table to your layers.
Select it, and then click Settings.
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.
Optionally, click Shape, and select a shape to distinguish the marker, such as an X or a star.
Scroll down to the box Limit data using expression, and click Edit.
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.