从firebase数据库获取marker info窗口中的用户数据android google maps

从firebase数据库获取marker info窗口中的用户数据android google maps,android,google-maps,firebase,google-maps-markers,geofire,Android,Google Maps,Firebase,Google Maps Markers,Geofire,通过使用Geofire和Firebase,我实现了获取附近用户的功能,但现在它只显示附近用户的标记,我还希望通过使用info窗口显示用户信息。那么如何让info窗口从firebase数据库获取JSON数据。通过使用info窗口进行实验,我得到了结果,但它只显示了我自己的信息,而这些信息来自客户端,而不是数据库。下面是代码 @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap

通过使用Geofire和Firebase,我实现了获取附近用户的功能,但现在它只显示附近用户的标记,我还希望通过使用info窗口显示用户信息。那么如何让info窗口从firebase数据库获取JSON数据。通过使用info窗口进行实验,我得到了结果,但它只显示了我自己的信息,而这些信息来自客户端,而不是数据库。下面是代码

  @Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    if (mMap != null){
        mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
            One one;
            @Override
            public View getInfoWindow(Marker marker) {
                return null;
            }

            @Override
            public View getInfoContents(Marker marker) {
                View view = getLayoutInflater().inflate(R.layout.user_infowindow,null);

                TextView nameInfo = (TextView) view.findViewById(R.id.usernameinfowindow);
                TextView fromInfo = (TextView) view.findViewById(R.id.filltextfrominfowindow);
                TextView toInfo = (TextView) view.findViewById(R.id.filltexttoinfowindow);
                CircleImageView profileInfo = (CircleImageView) view.findViewById(R.id.infowindowprofilepic);

                nameInfo.setText(user_name.getText());
                fromInfo.setText(eetsource.getText());
                toInfo.setText(eetdestination.getText());
                return view;
            }
        });
    }
这是我的数据库 &这是我的信息窗口布局

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/infowindowprofilepic"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_alignParentEnd="true"
        android:layout_gravity="top|end"
        app:border_color="@color/white"
        android:layout_alignParentRight="true" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_alignTop="@+id/infowindowprofilepic"
        android:layout_toLeftOf="@+id/infowindowprofilepic"
        android:layout_toStartOf="@+id/infowindowprofilepic">

        <TextView
            android:id="@+id/usernameinfowindow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top|start"
            android:text="@string/user_name_corider"
            android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

        <TextView
            android:id="@+id/textfrominfowindow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/five_dp_padding"
            android:text="@string/from_corider"
            android:textColor="@color/black" />

        <TextView
            android:id="@+id/filltextfrominfowindow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:maxLines="1"
            android:text="@string/your_starting_point"
            android:textSize="12sp" />

        <TextView
            android:id="@+id/texttoinfowindow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/to_corider"
            android:textColor="@color/black" />

        <TextView
            android:id="@+id/filltexttoinfowindow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:maxLines="1"
            android:text="@string/your_destination"
            android:textSize="12sp" />

    </LinearLayout>

pojo类,它帮助我在recycler视图中从数据库获取详细信息

public class One extends LocationData {

public String name;
public String from;
public String to;
public String when;
public CircleImageView picture;

public One(){
    // Default constructor required for calls to DataSnapshot.getValue(One.class)

}

public One(String name, String from, String to, String when, CircleImageView picture) {
    this.name = name;
    this.from = from;
    this.to = to;
    this.when = when;
    this.picture = picture;

}

@Exclude
public Map<String, Object> toMap() {
    HashMap<String, Object> result = new HashMap<>();
    result.put("name", name);
    result.put("from", from);
    result.put("to", to);
    result.put("when", when);
    result.put("picture", picture);
    return result;
}

@Override
public void setName(String name) {
    this.name = name;
}

@Override
public String getName() {
    return name;
}

@Override
public void setFrom(String from) {
    this.from = from;
}

@Override
public String getFrom() {
    return from;
}

@Override
public void setTo(String to) {
    this.to = to;
}

@Override
public String getTo() {
    return to;
}

@Override
public void setWhen(String when) {
    this.when = when;
}

@Override
public String getWhen() {
    return when;
}
公共一级扩展LocationData{
公共字符串名称;
来自的公共字符串;
公共字符串到;
公共字符串时;
公众图片;
公共一号{
//调用DataSnapshot.getValue(One.class)所需的默认构造函数
}
公共一个(字符串名称、字符串起始、字符串起始、字符串起始、字符串起始时间、圆圈图像视图图片){
this.name=名称;
this.from=from;
这个;
this.when=when;
这个图片=图片;
}
@排除
公共地图toMap(){
HashMap结果=新建HashMap();
结果。输入(“名称”,名称);
结果。放置(“from”,from);
结果.付诸表决(“to”,to);
结果。放入(“何时”,何时);
结果。把(“图片”,图片);
返回结果;
}
@凌驾
公共void集合名(字符串名){
this.name=名称;
}
@凌驾
公共字符串getName(){
返回名称;
}
@凌驾
public void setFrom(String from){
this.from=from;
}
@凌驾
公共字符串getFrom(){
返乡;
}
@凌驾
公共void设置为(字符串为){
这个;
}
@凌驾
公共字符串getTo(){
返回;
}
@凌驾
公共void setWhen(字符串when){
this.when=when;
}
@凌驾
公共字符串getWhen(){
何时返回;
}

}

您已将getInfoWindow设置为返回“null”。它没有显示视图。您需要添加

视图=GetLayoutFlater().充气(R.layout.user\u infowindow,null)

进入“获取信息”窗口并设置“返回到视图”

返回视图

问候,, -光盘