So, I have set infowindowadapter
for my Google map, but the problem is that when I click on the first marker, it shows the information correctly, but when I hit the second marker it shows information from the first one, so infowindowadapter
doesn't refresh.
Can someone tell me why that it and how to fix it?
I was following this post to set infowindowadapter
:
custom info window adapter with custom data in map v2
EDIT:
new getMarkers().execute();
mMap.setOnMarkerClickListener(new OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
marker.showInfoWindow();
return false;
}
});
mMap.setInfoWindowAdapter(new InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker marker) {
// TODO Auto-generated method stub
return null;
}
@Override
public View getInfoContents(Marker marker) {
View view = getLayoutInflater().inflate(R.layout.post_details_on_map,null);
date = (TextView)view.findViewById(R.id.txtMarkerDate);
comment = (TextView)view.findViewById(R.id.txtMarkerComment);
image = (ImageView)view.findViewById(R.id.ivMarkerPicture);
MyMarkerInfo mmi = markerMap.get(marker.getId());
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id",mmi.getId()));
MarkerDetails mDetails = new JSONAdapter().getMarkerDetails(params);
date.setText(mDetails.getDate());
comment.setText(mDetails.getComment());
new getPicture().execute(mDetails.getImageUrl());
return view;
}
});
}