androidgoogle-mapsgoogle-maps-markersitemizedoverlay

Android: How to to set imageView as a marker in google map API android?


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

this


Solution

  • Yeah I was wondering if I could do something like this, i.e. show a custom View instead of drawable. You can override draw() method, but unfortunately it always (someone please tell me I'm wrong) has to be drawable. I think it's because custom View 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 your OverlayItem and in this method inflate your ImageView. 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 this OverlayItem).