b = map_name.setMarkerOnClickInfoWindow(markerId, callbackFunction);
The
Map.setMarkerOnClick function sets the function that is called when the user taps on the popup info window for the marker identified by
markerId. The popup info window is shown when the user taps on the marker and it displays the marker description set by calling
Map.setMarkerDescription. After tapping on the marker to display the info window, when the user then taps on the popup, the user-defined function
callbackFunction will be called.
The
callbackFunction is the name of a user function defined in the global procedure. 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.setMarkerOnClickInfoWindow is called rather than at the time the callback is run. This allows you to reuse the same callback function for multiple markers and to customize the behavior of the callback by passing different arguments to the callback function for each marker.
The function returns a logical value of 1 (true) if the marker was found and the callback function was set successfully and 0 (false) if there is an error.
PROC GLOBAL
function clickedOnMarkerInfoWindow()
errmsg("You clicked on a marker popup");
end;
PROC SOMEITEM
// Declare a map
Map mymap;
// Add a marker to the map at latitude 38.84839, longitude -76.931098
numeric markerId = mymap.addMarker(38.84839, -76.931098);
// Set function that is called on marker info window click
mymap.setMarkerOnClick(markerId, clickedOnMarkerInfoWindow());
// Display the map
mymap.show();
PROC GLOBAL
function launchHouseholdQuestionnaire(string caseid)
Pff household_pff;
household_pff.setProperty("AppType", "Entry");
household_pff.setProperty("Key", caseid);
household_pff.setProperty("Application", "Household.ent");
household_pff.setProperty("InputData", "Household.csdb");
household_pff.setProperty("OnExit", "Menu.pff");
household_pff.exec();
end;
PROC SHOW_HOUSEHOLDS_ON_MAP
preproc
// Declare a map
Map mymap;
// Loop through all households in the listing dictionary
forcase LIST_DICT do
// Create a marker for household at latitude and longitude from listing file
numeric markerId = mymap.addMarker(LI_LATITUDE, LI_LONGITUDE);
// Set the marker description to the household head name.
// This will be displayed in the popup info window when the user taps the marker
mymap.setMarkerDescription(markerId, strip(LI_HOUSEHOLD_HEAD_NAME));
// When the info window is clicked launch household questionnaire application
// and prefill the ID items
string householdCode = key(LIST_DICT);
mymap.setMarkerOnClickInfoWindow(markerId, launchHouseholdQuestionnaire(householdCode));
endfor;