I have list of records, where each record has its own latitude and longitude. Based on these lat and long I need to display these records on map as pins.
This is my code to display the records on map:
private GoogleMap mMap;
List<Ticket> tickets = ticketDB.getMyTickets(ticketIDs, mCurrSortKey, mCurrSortOrder, currDate);
if (mMap != null) {
LatLngBounds.Builder bounds = new LatLngBounds.Builder();
for (int i = 0; i < tickets.size(); i++) {
Ticket ticket = tickets.get(i);
if (ticket != null && ticket.Latitude > 0) {
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(new LatLng(ticket.Latitude, ticket.Longitude));
bounds.include(new LatLng(ticket.Latitude, ticket.Longitude));
markerOptions.title(ticket.TicketNumber);
mMap.addMarker(markerOptions);
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(markerOptions.getPosition(),15));
}
}
Here, all the ticket records are fetched from database and are successfully marked on map.(Assume there are 10 tickets and so are 10 pins on the marker)
My problem is on clicking on each marker I need to send data of clicked record to open the activity. how to know which record is clicked?