• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
        • Map Statement
        • Map.show Function
        • Map.hide Function
        • Map.clear Function
        • Map.setTitle Function
        • Map.setBaseMap Function
        • Map.zoomTo Function
        • Map.showCurrentLocation Function
        • Map.saveSnapshot Function
        • Map.setOnClick Function
        • Map.getLastClickLatitude Function
        • Map.getLastClickLongitude Function
        • Map.addMarker Function
        • Map.removeMarker Function
        • Map.clearMarkers Function
        • Map.setMarkerImage Function
        • Map.setMarkerText Function
        • Map.setMarkerDescription Function
        • Map.setMarkerOnClick Function
        • Map.setMarkerOnClickInfoWindow Function
        • Map.setMarkerOnDrag Function
        • Map.setMarkerLocation Function
        • Map.getMarkerLatitude Function
        • Map.getMarkerLongitude Function
        • Map.addGeometry Function
        • Map.removeGeometry Function
        • Map.clearGeometry Function
        • Map.addTextButton Function
        • Map.addImageButton Function
        • Map.removeButton Function
        • Map.clearButtons Function
        • Base Map Specification
        • Offline Maps
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization 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.setOnClick Function

Format
b = map_name.setOnClick(callbackFunction);
Description
The Map.setOnClick function sets the function that is called when the user taps on the base map away from any markers. The callbackFunction is the name of a user function defined in the global procedure that will be called when the user taps on the map. The function name may optionally be followed by function arguments which will be passed to the function when it is run. These arguments are evaluated at the time that Map.setOnClick is called rather than at the time the callback is run.
To retreive the coordinates of the map location that was tapped, use the functions Map.getLastClickLatitude and Map.getLastClickLongitude.
If the user taps on a marker rather than on the map itself, callbackFunction is not called. To capture taps on markers use the Map.setMarkerOnClick function.
Return Value
The function returns a logical value of 1 (true).
Example
PROC GLOBAL

// Declare a map
Map mymap;

// Declare id for map marker
numeric markerId;

// This function is called when user taps on map.
// It moves the marker to the location that the user tapped.
function mapClicked()
   
numeric lat = mymap.getLastClickLatitude();
   
numeric lon = mymap.getLastClickLongitude();
    mymap.
setMarkerLocation(markerId, lat, lon);
end;

PROC SHOW_MAP
preproc

// Add a marker to the map at latitude 38.84839, longitude -76.931098
markerId = mymap.addMarker(38.84839, -76.931098);

// Set function that is called when the user taps on the map to move the marker
// to the new position
mymap.setOnClick(mapClicked());

// Display the map
mymap.show();
See also: Map Object, Map.setMarkerLocation Function, Map.setMarkerOnClick Function, Map.getMarkerLatitude Function, Map.getMarkerLongitude Function