I want to show an InfoWindow on markers in a Maps V2 fragment. Thing is, I want to show BitMaps that are dynamically loaded from the web with Universal Image Downloader.
This is my InfoWindowAdapter:
class MyInfoWindowAdapter implements InfoWindowAdapter {
private final View v;
MyInfoWindowAdapter() {
v = getLayoutInflater().inflate(R.layout.infowindow_map,
null);
}
@Override
public View getInfoContents(Marker marker) {
Item i = items.get(marker.getId());
TextView tv1 = (TextView) v.findViewById(R.id.textView1);
ImageView iv = (ImageView) v.findViewById(R.id.imageView1);
tv1.setText(i.getTitle());
DisplayImageOptions options = new DisplayImageOptions.Builder()
.delayBeforeLoading(5000).build();
imageLoader.getMemoryCache();
imageLoader.displayImage(i.getThumbnailUrl(), iv, options,
new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
// TODO Auto-generated method stub
}
@Override
public void onLoadingFailed(String imageUri, View view,
FailReason failReason) {
// TODO Auto-generated method stub
}
@Override
public void onLoadingComplete(String imageUri,
View view, Bitmap loadedImage) {
Log.d("MAP", "Image loaded " + imageUri);
}
@Override
public void onLoadingCancelled(String imageUri,
View view) {
// TODO Auto-generated method stub
}
});
return v;
}
@Override
public View getInfoWindow(Marker marker) {
// TODO Auto-generated method stub
return null;
}
}
I have 2 problems with this:
As we know the InfoWindow
is drawn and later changes to it (in my case the new BitMap
on the ImageView
) are not shown/ the InfoWindow
is not being updated. How can I "notify" the InfoWindow to reload itself when the imageLoader
has finished? When I put
marker.showInfoWindow()
into onLoadingComplete
it created an infinite loop where the marker will pop up, start loading the image, pop itself up etc.
My second problem is that on a slow network connection (simulated with the 5000ms delay in the code), the ImageView
in the InfoWindow
will always display the last loaded image, no matter if that image belongs to that ImageWindow
/ Marker
.
Any suggestions on how to propperly implement this?
An InfoWindow displays content (usually text or images) in a popup window above the map, at a given location. The info window has a content area and a tapered stem. The tip of the stem is attached to a specified location on the map. Info windows appear as a Dialog to screen readers.
An InfoWindow can be placed on a map at a particular position or above a marker, depending on what is specified in the options. Unless auto-pan is disabled, an InfoWindow will pan the map to make itself visible when it is opened. After constructing an InfoWindow, you must call open to display it on the map.
You can modify the whole InfoWindow using jquery alone... var popup = new google. maps. InfoWindow({ content:'<p id="hook">Hello World!
You should be doing Marker.showInfoWindow()
on marker that is currently showing info window when you receive model update.
So you need to do 3 things:
InfoWindowAdapter
markerShowingInfoWindow
)getInfoContents(Marker marker)
if (markerShowingInfoWindow != null && markerShowingInfoWindow.isInfoWindowShown()) {
markerShowingInfoWindow.showInfoWindow();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With