till now i was using drawable to populate marker on my map .Now i was wondering it would be cool if i could display custom imageview as a marker in map.
till now i am doing it like
itemized= new Itemazide(drawable, mContext);
i want to achieve something like
Yeah I was wondering if I could do something like this, i.e. show a custom
View
instead of drawable. You can overridedraw()
method, but unfortunately it always (someone please tell me I'm wrong) has to be drawable. I think it's because customView
would take too much memory.That being said, depending on what you're trying to achieve it's probably possible to hack mapview-baloon library to achieve some similar effect.
EDIT: Now that you've shown what you're trying to achieve I think you should override
draw()
in yourOverlayItem
and in this method inflate yourImageView
. But I didn't try to do it this way, so there may be some drawbacks (I remember a SO thread on a similar matter that claimed, that it would interrupt all touch events on thisOverlayItem
).I might be a bit late but I'll post a solution for others who have faced/are facing a similar issue. So basically what you have to do (at least for the solution you are seeking, i.e a custom image imposed on a box-like background) is impose the customImage on the background box with the help of a canvas. Using this implementation you can effectively create a BitmapDrawable from the canvas that you can then assign as a marker for your 'Overlay' / 'ItemizedOverlay'. Also, please refrain from creating an ImageView for each overlay as this will utterly destroy your memory/ your app if you have to deal with thousands of such ImageViews simultaneously. Instead, use BitmapDrawables that can be assigned to the overlays during their construction and don't consume nearly enough memory as an ImageView.