java - set callout image mapbox android -


in ios can set callout markers calling:

[marker setcanshowcallout:yes]; [marker setrightcalloutaccessoryview:your_button]; 

but can't find functionality mapbox android sdk. have listener detects touches on calloutview how can set callout image / button?

marker marker = new marker(p.gettitle(), p.getcatagoryname(), new latlng(p.getlatitude(), p.getlongitude()));                         marker.setmarker(getresources().getdrawable(getresources().getidentifier(string, "drawable", getactivity().getpackagename())));                                 mmapview.addmarker(marker);                          infowindow tooltip = marker.gettooltip(mmapview);                         view view = tooltip.getview();                         // view.setbackgroundresource(r.drawable.callout_button); not work                         view.setontouchlistener(new view.ontouchlistener() {                             @override                             public boolean ontouch(view view, motionevent motionevent) {                                 log.e(tag, "ontouch");                                  return true;                             }                         }); 

ryansh’s excellent response required include textviews ids tooltip_title , tooltip_description in custom layout. had add third tooltip_subdescription textview. default infowindow code assumes these views exist , crash if don’t. more control extended infowindow, overrode onopen , able use whatever layout wanted tooltip. overridden createtooltip in extended marker class, naturally instantiated , returned extended infowindow object.

update. here example of extending marker & infowindow support custom tooltip:

public class mapboxmarker extends marker {     private myinfowindow minfowindow;      public class myinfowindow extends infowindow {          public myinfowindow(int layoutresid, mapview mapview) {             super(layoutresid, mapview);         }          public void onopen(marker overlayitem) {             //             //  set data on minfowindow.getview()             //         }      }      public mapboxmarker(mapview mv, latlng alatlng, mapcontroller mapcontroller){         super(mv, "title", "description", alatlng);     }      @override     protected infowindow createtooltip(mapview mv) {         minfowindow = new myinfowindow(r.layout.custom_tooltip_layout, mv);         return minfowindow;     } } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -