How to show all title of marker in googlemap in android

I have three markers in my googlemap api v2. I am trying to show all of the marker names in one go. But it only shows the last marker (myMarker3). My code is below.

Marker myMarker1 = googleMap.addMarker(new MarkerOptions()
                    .position(myLoc1)
                    .title("Marker 1")
                    .icon(BitmapDescriptorFactory
                            .defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
            myMarker1.showInfoWindow();

Marker myMarker2 = googleMap.addMarker(new MarkerOptions()
                    .position(myLoc2)
                    .title("Marker 2")
                    .icon(BitmapDescriptorFactory
                            .defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
            myMarker2.showInfoWindow();

Marker myMarker3 = googleMap.addMarker(new MarkerOptions()
                    .position(myLoc3)
                    .title("Marker 3")
                    .icon(BitmapDescriptorFactory
                            .defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
            myMarker3.showInfoWindow();

      

Here myLoc1

, myLoc2

and myLoc3

are a type variable LatLng

with specific values ​​lat and lon.

+3


source to share


1 answer


Only one can be shown at a time because

  • This will break compatibility
  • it will take a lot of bitmaps to send over RPC.


Therefore, use a custom marker icon and a Canvas to draw a marker title that might look like an information window. Also you can use the official utils here .

See here and here for more details .

+4


source







All Articles