Johnny Doe
Johnny Doe

Reputation: 3330

Label at the top of the marker in google maps api v2

One more problem while switching to the maps api v2. This is an ugly representation of what i want to achieve.

Edit1. There can be several markers, every marker with its own label. All markers and labels are shown simultaneously.

enter image description here

As you can see there is a label with some information at the top of the marker. While using api v1 it can easily be done with drawing marker and label on Overlay.

How can I implement it using api v2?

The first idea is to render marker(red) and label(black) to one bitmap and set it as marker. But it will significantly increase marker area(red rectangle) and with this marker limitation gives me real headache with user to map interraction realisation.

The second idea is to use GroundOverlay, but at first glance, it is not designed for this purpose.

Edit2 Here is similar question, solution, like in the first idea, is to use both marker and label as single marker bitmap, created from view.

Upvotes: 2

Views: 6737

Answers (2)

Chris Broadfoot
Chris Broadfoot

Reputation: 5112

Have a look at a library I am working on: googlemaps/android-maps-utils

You can use the BubbleIconFactory to achieve this:

BubbleIconFactory

IconGenerator factory = new IconGenerator(this);
Bitmap icon = factory.makeIcon("11:15 1.08.2013");

mMap.addMarker(new MarkerOptions().position(...).
    icon(BitmapDescriptorFactory.fromBitmap(icon)));

Upvotes: 8

Levin Tacandong
Levin Tacandong

Reputation: 11

This is much simpler to do on Android Maps v2. Please take a look at the official documentation here: https://developers.google.com/maps/documentation/android/marker

It is called Info Window. By default, an info window is displayed when a user taps on a marker and if the marker has a title set

Upvotes: 1

Related Questions