Android : Fill map infoWindow with the data of a ParseUser in android

on Saturday, October 11, 2014


I'am having problems when filling an infoWindow of a map with data from a ParseUser. I have the objectId from the ParseUser as the title of the marker. Then when clicking on the marker, I want to display an infowindow filling its contents with data from that parseUser. I get the ObjectId from the marker title and then a I do a findInBackground.


This is the code inside the infowindow:



mMap.setInfoWindowAdapter(new InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker marker) {
// TODO Auto-generated method stub
return null;
}
@Override
public View getInfoContents(Marker marker) {
View v = getLayoutInflater().inflate(
R.layout.custom_infowindow, null);
title = (TextView) v.findViewById(R.id.restaurantName);
String objectId = marker.getTitle();
ParseQuery < ParseUser > query = ParseUser.getQuery();
query.whereEqualTo("restaurant", true);
query.whereEqualTo("objectId", objectId);
query.findInBackground(new FindCallback < ParseUser > () {
public void done(List < ParseUser > objects,
ParseException e) {
if (e == null) {
if (objects.size() > 0) {
for (int i = 0; i < objects.size(); i++) {
ParseObject p = objects.get(i);
title.setText(p.getString("restaurantname"));
}
}
} else {
title.setText("merda mes gran");
}
}
});
return v;
}
});


The problem comes when I click on the marker and nothing is displayed inside the infowindow. I think that the problem is in the search of the user and accessing to the data I want, because when I do not do this search and set the title text manually, then I have the text I want in the infowindow when clicking the marker.


I also have tried to change the way of accessing to the item in te objescts list inside the FindCallback but every way has the same result: nothing is displayed in the infowindow.


0 comments:

Post a Comment