3

Hello I would like to add a dynamic display with a number in my point.

As in the picture, I already have the icons on the map.

Adding the numbers in point?

enter image description here

Wouter J
  • 41,455
  • 15
  • 107
  • 112
user2568768
  • 167
  • 1
  • 3
  • 13

1 Answers1

5

You may use android-maps-utils to achieve such effect.

Simply create 9-patch out of your pin with empty rectangle above and make rectangle be the content.

Then use IconGenerator to create a Bitmap with your text and 9-patch like here:

IconGenerator factory = new IconGenerator(context);
factory.setBackground(your9PatchDrawable);
factory.setContentView(textViewWithWith3Point600String);
Bitmap icon = factory.makeIcon();

Then use this Bitmap to set Markers icon:

map.addMarker(new MarkerOptions().icon(BitmapDescriptorFactory.fromBitmap(icon)...);
Chris Broadfoot
  • 5,082
  • 1
  • 29
  • 37
MaciejGórski
  • 22,187
  • 7
  • 70
  • 94
  • Yes! exactly this.. but i can't import the library in Eclipse... The lib don't shows me when i try to import it... Do you know how can i do this? – user2568768 Aug 21 '13 at 12:05
  • It's works, THANKS!! But the BubbleIconFactory is deprecated i used TextIconGenerator, is the same... thanks again. – user2568768 Aug 21 '13 at 12:41
  • @ChrisBroadfoot These classes change names too often ;) – MaciejGórski Jan 09 '14 at 08:37
  • @MaciejGórski I know! Sorry. It only changed once between 0.1 and 0.2 though! (but another time on HEAD) – Chris Broadfoot Jan 10 '14 at 00:41
  • @MaciejGórski :factory.setContentView(textViewWithWith3Point600String); What is the argument here. Can a simple text view be put in that? – Ashwin Feb 08 '15 at 07:25
  • @Ashwin Yes. I thought that variable `textViewWithWith3Point600String` would be good enough to describe that it's a simple `TextView` with `"3.600"` as its text. – MaciejGórski Feb 08 '15 at 14:12
  • @MaciejGórski : But then why is this not working - http://stackoverflow.com/questions/28384422/android-map-utils-text-not-showing-in-custom-marker-content – Ashwin Feb 08 '15 at 17:00
  • @Ashwin I don't know. The API of that library had a few breaking changes, so it's possible you do that differently right now. Might be worth asking on [android-maps-utils issues](https://github.com/googlemaps/android-maps-utils/issues). – MaciejGórski Feb 09 '15 at 09:42
  • I need the same for iOS... does anyone know how to do it for iOS ? – Nav Apr 24 '15 at 17:22
  • I've done this but the icon is stretching as well, distorting the whole image! How can I define the TextView to be the only part to be stretched? Can you guys provide more detail on this solution? I'd be immensely grateful, getting mad on this. – transient_loop May 01 '15 at 20:23
  • 1
    @faboolous, i did this using the setContentView method, you just need to have a textview with id "text" in that view. http://googlemaps.github.io/android-maps-utils/javadoc/com/google/maps/android/ui/IconGenerator.html#setContentView-View- – TrueCoke Aug 03 '15 at 23:14