-1

I have a google map with some markers and all of them have title and snippet. I store markers in a HashMap. I want to display title and snippet with showInfoWindow() function when a button clicked. this is my code :

Marker m = getMarker(location); //this function return marker from HashMap with its location
if(m!=null)
    m.showInfoWindow();

m is not null, but showInfoWindow() doesn't work

debug output: enter image description here

m.getTitle() log : enter image description here

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

2 Answers2

0

Change your code to this

    Marker m = getMarker(location);
if(m!= null){
    m.showInfoWindow();
}

The Marker object will be null if the marker has not been rendered on the map yet so be sure to check that the marker object is not null before using it.

Sakar Mehra
  • 89
  • 1
  • 11
0

For showing infoWindow your marker must be have a title.

 MarkerOptions marker = new MarkerOptions().position(location)
                .icon(BitmapDescriptorFactory.fromBitmap(aBitmapFile))
                .title("The Title"); //here is title
        mapPoint p = new mapPoint(lat, lng);
        googleMap.addMarker(marker);

then you can call: .showInfoWindow(); on your marker.

javadroid
  • 1,421
  • 2
  • 19
  • 43