For my application, I am currently displaying 12 markers on a map, each of which triggers a dialog box showing the location's address when tapped. However, I believe there is a more efficient way to handle this. I have been experimenting with creating a list to store all the markers and passing them to the dialog box when needed, rather than creating 12 separate dialog boxes.
Currently, the markers are being displayed on the screen, but the dialog box does not appear when a marker is tapped. It only works when using the 12 separate dialog boxes. Can anyone suggest where the issue might be?
private List<Marker> markers = new ArrayList<Marker>();
// Default map location set to Glasgow
double defaultLat = 55.85432829452839;
double defaultLng = -4.268357989501965;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_muc_main);
// Drawable IDs
// Code below contains drawable IDs
// Array adapter for spinner
// Code below contains array adapter setup
// Check if the map is instantiated, if not then instantiate it
if(mMap == null)
{
// Code below passes the map fragment ID and gets the Google Map object
}
if(mMap != null)
{
defaultSetting();
addListenerOnChkIos();
mMap.setOnMarkerClickListener(this);
}
}
// Code below includes onItemSelected, onNothingSelected, showUserLocation, defaultSetting, addMarkers, onMarkerClick methods