Show and Hide Info Window Automatically in Android with GMaps
Info window is a window that located on the top of marker in maps. When you add a marker to your map, the info window will not be shown by default. Sometimes you want to show it automatically when it is added to your map or you want to hide it for some reason. You can do it with this simple code.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
MarkerOptions pin = new MarkerOptions(); pin.position(new LatLng(nearest.getLatitude(), nearest.getLongitude())); pin.title(nearest.getName()); pin.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_icon)); // Save marker object in a variable Marker marker = map.addMarker(pin); // Show info window marker.showInfoWindow(); // Hide info window marker.hideInfoWindow(); |
That’s all. Remember that you can just show 1 info window at the same time. 😀
Thanks a lot for this post..I was struggling from whole day….Ur post save me…:)
Hi Anushka, glad it can help! 🙂