Social Event Voting
This example demonstrates how to create an app with an interactive map that allows users to vote and view social events, using the Maps SDK.
Map Integration
When the map is loaded, SdkSettings.onMapDataReady = a touch handler is defined to get the screen position where a user tap occurred: gemSurfaceView.mapView?.onTouch = xy -> then the xy screen position is set so the mapView can use it to search for map elements near that position: gemSurfaceView.mapView?.cursorScreenPosition = xy
When the user taps on the map, the overlay items, if any, near the tap position are obtained:
val overlays = gemSurfaceView.mapView?.cursorSelectionOverlayItems
and if the array is not empty, then the first item, at index 0, is selected:
val overlay = overlays[0]
and if it is a social reports item,
if (overlay.overlayInfo?.uid == ECommonOverlayId.SocialReports.value)
then the voting panel is displayed:
Util.postOnMain { showVotingPanel(overlay) }
Social Events Interaction
The showVotingPanel() function first makes the voting container panel visible, if it is not eventVotingContainer.visibility = View.VISIBLE
Next, the time of the event is converted to hours and minutes, if it occurred today, or in day, month and year format otherwise.
The icon image associated with the event is icon.setImageBitmap(bitmap).
The number of votes displayed in the upper right corner of the panel is the score.text = scoreStr whereas the name of the event is text.text = textStr and the date/time is time.text = timeStr.
A click listener is set for the panel, setOnClickListener and the panel is made to disappear when the user clicks on it: eventVotingContainer.visibility = View.GONE

