android, add Marker from Bitmap on googlemap -
i'm using googlemap-android-api v2, , want create marker bitmap @ runtime. do:
bitmapfactory.options options = new bitmapfactory.options(); options.inpreferredconfig = bitmap.config.argb_8888; bitmap bitmap = bitmapfactory.decodefile(filepath, options); //create thumbnail use marker bitmap thumbnail = thumbnailutils.extractthumbnail(bitmap,10,10); markeroptions markeroptions = new markeroptions().position(currentlatlng).icon(bitmapdescriptorfactory.frombitmap(thumbnail)); mmap.addmarker(markeroptions) it never seems work, i'm sure both bitmap , thumbnail not null. if instead of .frombitmap, use .fromresource(r.drawable.some_image) shows. however, said, want change @ run-time user's input.
any tip? thanks
updated: marker show if add (i.e, use above code) @ onresume() of activity/fragment host map. before use code @ onactivityresult(), after user browse file filepath. me, it's still strange since onactivityresult() on ui thread. anyway, whatever works.
i doing same following
first create drawable path on runtime
drawable drawable = drawable.createfrompath(filepath); then add marker this
mmap.addmarker(new markeroptions() .position(location) .title(title) .icon(bitmapdescriptorfactory.frombitmap(((bitmapdrawable)drawable).getbitmap()))); i hope helps.
Comments
Post a Comment