Google Maps Utils IconGenerator text styles and background

Viewed 9308

I just started using Google Maps Utils library so that I can have markers with text in them. I understand the library so far and I'm successfully using it. Code snippet:

IconGenerator icnGenerator = new IconGenerator(this);
Bitmap iconBitmap = icnGenerator.makeIcon(item.placeItemName);

    myPlaceItemMarkers.add(mMap.addMarker(new MarkerOptions().position(new LatLng(item.latitude, item.longitude))
                .icon(BitmapDescriptorFactory.fromBitmap(iconBitmap)).anchor(0.5f, 0.6f)));

Now I started playing around with styling the window a bit and there are two functions that interest me in particular:

icnGenerator.setBackground(Drawable background);
icnGenerator.setTextAppearance(int resid);

I looked up for info on docs and there's only info for BubbleIconFactory which is deprecated. Could someone tell me how to use these 2 functions? I know setTextAppearance is for changing text style but how do I do it? And if I'm not wrong setBackground is for setting custom marker background, but I don't know how to use that either.

3 Answers

if you're just wanting to change away from the default marker styling without getting fancy you can do this.

icnGenerator.setStyle(IconGenerator.STYLE_BLUE)

There's currently 7 basic styles to select from:

IconGenerator.STYLE_BLUE 
IconGenerator.STYLE_DEFAULT 
IconGenerator.STYLE_GREEN 
IconGenerator.STYLE_ORANGE 
IconGenerator.STYLE_PURPLE 
IconGenerator.STYLE_RED 
IconGenerator.STYLE_WHITE 

doc: https://www.javadoc.io/doc/com.google.maps.android/android-maps-utils/latest/com/google/maps/android/ui/IconGenerator.html

Related