I’m adding dynamically a non-fixed amount of markers in a map, which each of them are related to one instance of my POCO class.
I need to link them so when the user clicks on one of the markers, I show the rest of the data inside the custom InfoWindow.
What do you suggest?
PS: I add new markers everytime the user pans or zooms the map and I worried about overloading the app. Are the non visible markers disposed?
I suggest using a HashMap or something similar. As you iterate over your list of objects and create markers for them, also add the Marker to a list, using the ID of the object as the key, and the marker as the value:
…
Then you can use a OnInfoWindowClickListener to find the object id of the tapped marker in your Map and do something with the corresponding data, like open a new activity with details.