Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening InfoWindow automatically when adding marker Google Maps v2 Android

Is there a way to open the infowindow automatically when we add a marker? Using this code to add the marker but infowindow only opens when clicking the marker:

myMap.addMarker(new MarkerOptions()             .position(latLng)             .title("Title")             .snippet("Snippet")             .icon(BitmapDescriptorFactory                     .fromResource(R.drawable.marker))); 
like image 257
bond Avatar asked Apr 09 '13 10:04

bond


People also ask

How do I get rid of InfoWindow in Google Maps?

After constructing an InfoWindow, you must call open to display it on the map. The user can click the close button on the InfoWindow to remove it from the map, or the developer can call close() for the same effect.

How do I know if InfoWindow is open?

Calling InfoWindow. getOpenedState() returns a boolean which reflects the state (opened/closed) of the infowindow.

What is InfoWindow in Google map?

An InfoWindow displays content (usually text or images) in a popup window above the map, at a given location. The info window has a content area and a tapered stem. The tip of the stem is attached to a specified location on the map. Info windows appear as a Dialog to screen readers.


1 Answers

According to the documents of Google Maps for Android V2:

An info window allows you to display information to the user when they tap on a marker on a map. By default, an info window is displayed when a user taps on a marker if the marker has a title set. Only one info window is displayed at a time. If a user clicks on another marker, the current window will be hidden and the new info window will be displayed. You can show an info window programmatically by calling showInfoWindow() on the target marker. An info window can be hidden by calling hideInfoWindow().

You can show the info window like this:

Marker marker = myMap.addMarker(new MarkerOptions()                      .position(latLng)                      .title("Title")                      .snippet("Snippet")                      .icon(BitmapDescriptorFactory                      .fromResource(R.drawable.marker)));  marker.showInfoWindow(); 
like image 166
dumbfingers Avatar answered Sep 23 '22 03:09

dumbfingers