我有記錄列表,每個記錄都有自己的經度和緯度。 基於這些緯度和長度,我需要在地圖上顯示這些記錄作爲引腳。在谷歌地圖上填充針腳並點擊每個針腳項目打開活動
這是我的代碼,在地圖上顯示的記錄:
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));
}
}
在這裏,所有的售票記錄是從數據庫中提取,併成功地標註在地圖上(假設有10張等10個引腳在標記)
我的問題是點擊每個標記我需要發送點擊記錄的數據來打開活動。如何知道點擊哪條記錄?
https://stackoverflow.com/questions/14226453/google-maps-api-v2-how-to-:
並且可被取make-marker-clickable –
這可能有所幫助:https://stackoverflow.com/questions/30601892/android-google-maps-how-to-make-each-marker-infowindow-open-different-activity –