java - Add different layout of infoWindow to marker -


i have couple of markers on map. each 1 of them, want inflate custom infowindow.

the problem i'm having infowindow same each one. have read couple of stack threads haven't figured out how fix it.

snippet add markers map

        (int = 0; i<cityobjects.size(); i++){             cityobject cobject = cityobjects.get(i);             coordinates loc = cobject.getcoordinates();             latlng pos = new latlng(loc.getlatitude(), loc.getlongitude());             mmap.addmarker(new markeroptions().position(pos).title(cobject.getname()));             loadinfowindow(cobject.getimgs().get(0), cobject.getname());              builder.include(pos);         } 

method inflate custom infowindow

    public void loadinfowindow(final string url, final charsequence title) {         mmap.setinfowindowadapter(new googlemap.infowindowadapter() {               @override             public view getinfowindow(marker arg0) {                 arg0.getid();                 view v = getactivity().getlayoutinflater().inflate(r.layout.layout_info_window, null);                 button info = (button) v.findviewbyid(r.id.infobutton);                 info.settext(title);                 bitmaplayout = (bitmaplayout) v.findviewbyid(r.id.bitmapbackground);                 picasso.with(getcontext()).load(url).into(back);                  return v;              }              @override             public view getinfocontents(marker arg0) {                  return null;             }         });      } 

i read setinfowindowadapter being setter , therefore overrides infowindow each time for-loop iterates. have solution on how recognize markers can inflate different layouts?

you can use marker.settag() , marker.gettag(). can give tag marker.for example

mmap.addmarker(new markeroptions().position(pos).title(cobject.getname())).settag(1);  mmap.addmarker(new markeroptions().position(pos).title(cobject.getname())).settag(2); 

and in loadinfowindow method

   if((int)arg0.gettag==1)   {   //do   }  else{  //do  } 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -