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.
To display a map, call the
Map.show function. The map will be displayed allowing the user to interact with it until the user taps the back button or the
Map.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.
By default, the map contains a button to zoom to the users current location. You can add additional buttons to the map by calling
Map.addImageButton or
Map.addTextButton.
You add vector geometry, such as polygons and polylines, to the map using the
Map.addGeometry function.
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
offline map file to your device and pass the file to the
Map.setBaseMap function.
A
Map is a CSPro logic object that allows the following functions to be called via
dot notation:
// Declare a map
Map mymap;
// Add a marker to the map at latitude 38.84839, longitude -76.931098
mymap.addMarker(38.84839, -76.931098);
// Display the map
mymap.show();