Try to add a picture marker google maps with android studio -


i tried add drawable in marker google maps doesn't worked. followed many tutorials , tried many things without success... can me ?

this code :

i think problem ".icon(icon)"

public void onmapready(googlemap googlemap) {     mmap = googlemap;     bitmapdescriptor icon = bitmapdescriptorfactory.fromresource(r.drawable.ic_radar);      // add marker in sydney , move camera     latlng sydney = new latlng(-34, 151);     mmap.addmarker(new markeroptions().position(sydney).title("marker in sydney").icon(icon));     mmap.movecamera(cameraupdatefactory.newlatlng(sydney)); } 

you have first change bitmapdrawable convert bitmap, can add image marker, this:

public void onmapready(googlemap googlemap) {     mmap = googlemap;     bitmapdrawable bitmapdraw=(bitmapdrawable)getresources().getdrawable(r.drawable.icon);     bitmap b=bitmapdraw.getbitmap();     bitmap smallmarker = bitmap.createscaledbitmap(b, 84, 84, false);      // add marker in sydney , move camera     latlng sydney = new latlng(-34, 151);     mmap.addmarker(new markeroptions().position(sydney).title("marker in sydney").icon(bitmapdescriptorfactory.frombitmap(smallmarker)));     mmap.movecamera(cameraupdatefactory.newlatlng(sydney));     } 

i hope help.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -