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 map functions to add markers, buttons, set the base map, 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.
You can add markers to the map using the addMarker
function. You can replace the default marker icon with a custom image by calling setMarkerImage
or with a text icon using setMarkerText
By default, the map contains a button to zoom to the users current location. You can add additional buttons to the map by calling addImageButton
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
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