In logic, a map
is an object that can be used to display and control an interactive map. The map may be panned and zoomed with touch controls and may optionally show the user's current location. Using map functions you can add markers at geographic positions on the map, add custom buttons, and set the geographical area displayed. You can also specify user-defined functions in your logic to be called when the user taps on markers, buttons, and on the map itself. Together, these functions allow for rich map-based interactions such as showing households on a map and launching an interview when the user taps a household.
Note that maps are currently only supported on Android. The map functions will do nothing when run on Windows.
To display a map, call the show
function. The map will be displayed allowing the user to interact with it until the user taps the back button or the hide
function is called from program logic.
You can call the map functions to add markers, buttons, set the basemap, and pan/zoom before showing the map. This will be more efficient than adding them afterwards, especially when adding large numbers of markers. You can also call the map functions after showing the map from within any of the user defined callback functions for map, marker and button clicks and drags.
By default, the map will display a base map from Google Maps which requires an internet connection. With no internet connection the base map will be empty. To display a map without an internet connection you can copy an an offline map file to your device and pass the file to the setBaseMap
function. See offline maps
A map is a CSPro logic object and the following functions can be called via dot notation
// Declare a map
// Add a marker to the map at latitude 38.84839, longitude -76.931098
// Display the map