Java – How to display all markup headers in googlemap in android

How to display all markup headers in googlemap in android… here is a solution to the problem.

How to display all markup headers in googlemap in android

There are three tags in my GoogleMap API v2. I’m trying to show all tag headers at once. But it only shows the last tag (myMarker3) title. My code is as follows.

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();

myLoc1, myLoc2, and myLoc3 are variables of type LatLng with specific latitudes and longitudes.

Solution

Only one can be displayed at a time, because

  • That would break compatibility
  • Many bitmaps need to be sent over RPC.

Therefore, use custom marker icons and Canvas to draw markup titles that look like information windows. You can also use the official tool here

For more details, quote here and here .

Related Problems and Solutions