我正在使用材料搜索视图。我正在做的是将所有位置显示为建议,我想做的是单击建议后,它从Firebase数据库中读取其相应的经度和纬度并显示地图上的那个位置,但是当我单击建议时,什么也没发生。
.Java :
@Override
public boolean onQueryTextSubmit(final String query) {
String searchView = materialSearchView.toString();
mLocations=FirebaseDatabase.getInstance().
getReference("Locations_Information");
mLocations.child("locationTitle").equalTo(searchView).
addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot s : dataSnapshot.getChildren()) {
LocationInformation locationInformation = s.getValue(LocationInformation.class);
LatLng location = new LatLng(locationInformation.latitude, locationInformation.longitude);
CameraUpdate update = CameraUpdateFactory.newLatLngZoom(location, 18);
mMap.animateCamera(update);
materialSearchView.clearSuggestions();
materialSearchView.closeSearch();
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
return true;
}