• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
      • Introduction to CSPro Language
      • Data Requirements
      • CSPro Program Structure
      • Programming Standards
      • Code Folding
      • Debugging CSPro Applications
      • Declaration Section
        • Compiler Mode
        • Variables
        • Alias Statement
        • User-Defined Functions
        • Array Object
        • Audio Object
        • Case Object
        • Document Object
        • File Object
        • Freq Object
        • Geometry Object
        • HashMap Object
        • Image Object
        • List Object
        • Map Object
        • Pff Object
        • SystemApp Object
        • ValueSet Object
      • Procedural Sections
      • Logic
      • Language Elements
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Map Object

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.
You can add markers to the map using the Map.addMarker function. You can replace the default marker icon with a custom image by calling Map.setMarkerImage or with a text icon using Map.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 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.
Functionality
A Map is a CSPro logic object that allows the following functions to be called via dot notation:
FunctionDescription
showDisplay the map and allow the user to interact with it.
hideEnd displaying the map if it is currently showing.
clearReset the map's properties to the default state.
 
setTitleSet the map title.
setBaseMapChange the map source to an online or offline base map.
zoomToPan/zoom the map.
showCurrentLocationDisplay the current location (as retrieved from the GPS) on the map.
saveSnapshotSave the currently-displayed map as an image.
 
setOnClickSet the user-defined function that is called when the user taps on the map.
getLastClickLatitudeRetrieve the latitude of the last point on the map the user tapped.
getLastClickLongitudeRetrieve the longitude of the last point on the map the user tapped.
 
addMarkerPlace a marker on the map at the specified latitude and longitude.
removeMarkerDelete a single marker from the map.
clearMarkersDelete all markers from the map.
setMarkerImageSet the icon displayed on the map for a specific marker.
setMarkerTextSet text displayed on the map for a specific marker.
setMarkerDescriptionSet text displayed in a popup window when a specific marker is tapped.
setMarkerOnClickSet the user-defined function that is called when the user taps a marker.
setMarkerOnClickInfoWindowSet the user-defined function that is called when the user taps on a marker's popup info.
setMarkerOnDragSet the user-defined function that is called when the user a drags a marker on the map.
setMarkerLocationMove an existing marker to a new position on the map.
getMarkerLatitudeRetrieve the latitude of a marker on the map.
getMarkerLongitudeRetrieve the longitude of a marker on the map.
 
addGeometryAdd vector geometry to the map.
removeGeometryDelete vector geometry from the map.
clearGeometryDelete all vector geometry from the map.
 
addTextButtonCreate a button with a text label on the map.
addImageButtonCreate a button with an icon on the map.
removeButtonDelete a button on the map.
clearButtonsDelete all buttons from the map.
 
getLabelReturns the symbol's label.
getNameReturns the symbol's name.
getJsonReturns the symbol's metadata represented in JSON.
Assignments
When a Map object is used as an argument to a user-defined function, it is passed by reference.
Example
// 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();
See also: Display the Case Listing on a Map, Geometry Object