【发布时间】:2015-09-22 19:58:00
【问题描述】:
我正在使用 Google Maps Api,并希望在单击标记时在 InfoWindow 中显示图像。我实现了它,但毕加索有一个问题。当我单击标记时,会显示 infoWindow 并且 imageView 显示占位符图像。如果我再次单击相同的标记,毕加索会成功加载图像。我必须点击两次,太奇怪了。
截图便于理解:
首先点击标记:
当我再次点击时:
下面是我的代码:
InfoWindowAdapter(毕加索在此处加载)
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
View myContentsView = getLayoutInflater().inflate(R.layout.map_info_content, null);
ImageView imageView = (ImageView) myContentsView.findViewById(R.id.imgView_map_info_content);
Picasso.with(MainActivity.this)
.load(marker.getSnippet())
.placeholder(R.drawable.ic_placeholder)
.into(imageView);
return myContentsView;
}
});
设置标记(使用sn-p传递图片url)
for (MediaFeedData item : mItemList) {
LatLng position = new LatLng(item.getLocation().getLatitude(),
item.getLocation().getLongitude());
mMap.addMarker(new MarkerOptions()
.snippet(item.getImages().getLowResolution().getImageUrl())
.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_point))
.position(position));
}
InfoWindow 布局 xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imgView_map_info_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
【问题讨论】:
-
类似的问题(Fabric for Twitter - Picasso),无解stackoverflow.com/questions/32715198/…
-
所以这与毕加索无关。 InfoWindowAdapter 无法正常工作
标签: android google-maps-markers google-maps-android-api-2 picasso