Dynamic contents in Maps V2 InfoWindow

后端 未结 4 779
陌清茗
陌清茗 2020-11-29 03:24

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.

相关标签:
4条回答
  • 2020-11-29 04:05

    I was also faced same situation and solved using the following code.

    In my adapter I have added public variable

    public class MarkerInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
    
        public String ShopName="";   
    
        -------
        -------
    
         @Override
        public View getInfoWindow(Marker arg0) {
    
             View v;
             v = mInflater.inflate(R.layout.info_window, null);
    
             TextView shop= (TextView) v.findViewById(R.id.tv_shop);
    
             shop.setText(ShopName);
    
    
        }
    }
    

    and added MarkerClickListener in my main activity

    ----
    
    MarkerInfoWindowAdapter mMarkerInfoWindowAdapter;
    
    ----
    ----
    
    @Override
    public void onMapReady(GoogleMap googleMap) {
    
    
        mMarkerInfoWindowAdapter = new MarkerInfoWindowAdapter(getApplicationContext());
    
    
    
        mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
    
            @Override
            public boolean onMarkerClick(final Marker arg0) {
    
                mMarkerInfoWindowAdapter.ShopName= "my dynamic text";
    
                arg0.showInfoWindow();
    
                return true;
            }
        }
    
        mMap.setInfoWindowAdapter(mMarkerInfoWindowAdapter);
    
    
    }
    
    0 讨论(0)
  • 2020-11-29 04:05

    I've used the code in this article, and it worked well.

    http://androidfreakers.blogspot.de/2013/08/display-custom-info-window-with.html

    0 讨论(0)
  • 2020-11-29 04:07

    I did something similar. This was still giving me the recession error

    if (markerShowingInfoWindow != null && markerShowingInfoWindow.isShowingInfoWindow()) {
        markerShowingInfoWindow.showInfoWindow();
    }
    

    So what i did was simply closes the window and open it again

    if (markerShowingInfoWindow != null && markerShowingInfoWindow.isShowingInfoWindow()) {
    
        markerShowingInfoWindow.hideInfoWindow();
        markerShowingInfoWindow.showInfoWindow();
    
    }
    

    for a better detail version of the same answer here is my original soultion LINK

    0 讨论(0)
  • 2020-11-29 04:19

    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:

    1. create model and not put all the downloading into InfoWindowAdapter
    2. save reference to Marker (call it markerShowingInfoWindow)
      from getInfoContents(Marker marker)
    3. when model notifies you of download complete call
    if (markerShowingInfoWindow != null && markerShowingInfoWindow.isInfoWindowShown()) {
        markerShowingInfoWindow.showInfoWindow();
    }
    
    0 讨论(0)
提交回复
热议问题