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

依然范特西╮ 提交于 2019-12-11 07:49:29

问题


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.

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.


回答1:


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

You can use the BubbleIconFactory to achieve this:

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

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



回答2:


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



来源:https://stackoverflow.com/questions/17989389/label-at-the-top-of-the-marker-in-google-maps-api-v2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!