我正在使用Android应用程序.用户在谷歌地图上搜索餐馆.在谷歌地图显示所有邻居的餐厅标记.如果他点击标记,它会显示自定义InfoWindow.我的问题是我无法加载返回谷歌的图像.我正确的图像的网址,但我不能在窗口显示它.
信息窗口
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/bg_color" >
<ImageView
android:id="@+id/place_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"" />
<TextView
android:id="@+id/place_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/place_vicinity"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/bg_color" >
<RatingBar
android:id="@+id/place_rating"
style="?android:attr/ratingBarStyleSmall"
android:numStars="5"
android:rating="0"
android:isIndicator="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip" />
<ImageView
android:id="@+id/navigate_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:src="@drawable/navigate" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在创造我有这个
mGoogleMap.setInfoWindowAdapter(new InfoWindowAdapter() {
// Use default InfoWindow frame
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
// Defines the contents of the InfoWindow
@Override
public View …Run Code Online (Sandbox Code Playgroud) 我尝试将带有Picasso的Firebase存储中的图像加载到一个Imageview中,该Imageview放置在Marker的InfoWindowAdapter中.
我非常绝望.问题是Picasso只显示占位符Icon.
我的代码FirebaseStorageRefernce看起来像这个引用此Firebase博客文章:
StorageReference load = getImage(id);
load.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
downloadUri = uri;
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e("Failure",e.toString());
}
});
Run Code Online (Sandbox Code Playgroud)
我得到的downloadUri是有效的,工作正常.现在我使用这个下载Uri for Picasso.
Picasso picasso = new Picasso.Builder(getApplicationContext()).listener(new Picasso.Listener() {
@Override
public void onImageLoadFailed(Picasso picasso, Uri uri, Exception e) {
e.printStackTrace();
}
}).build();
picasso.setLoggingEnabled(true);
picasso.load(downloadUri).placeholder(R.drawable.toxic_bait_icon).fit().into(thump, new MarkerCallback(marker));
Run Code Online (Sandbox Code Playgroud)
参考我在StackOverFlow上找到的答案,我做了一个MarkerCallback类:
public class MarkerCallback implements Callback {
com.google.android.gms.maps.model.Marker marker = null;
MarkerCallback(Marker marker)
{ …Run Code Online (Sandbox Code Playgroud)