'Google maps hide marker title in Android
I'm trying to add a Marker into my Google map. Here is the code.
private final LatLng LOCATION_HOME= new LatLng(6.0334009,80.218384);
mMap.addMarker(new MarkerOptions()
.position(LOCATION_HOME)
.title("Hi I'm Home..:D")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE))
);
Using this code, I can get the marker title by touching the marker. How can I hide the marker title by toucing it again?
I tried to find a method. But, goggle say only how to hide the markers. but, I need the marker to stay and hide only the marker title.
Thanks in advance.
Solution 1:[1]
You can use this callback to manage the click on the info window.
mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
}
});
Or maybe its better for you to implement this method:
public boolean onMarkerClick(Marker marker)
Then you can call
hideInfoWindow()
on the marker to hide it.
Hope this helps.
Solution 2:[2]
First create a marker variable
Marker mMarker = mMap.addMarker(markerOptions);
Then make sure that marker is tapped
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
if (marker.equals(mMarker))
marker.hideInfoWindow();
return true;
}
});
You can also implement mMap.setOnInfoWindowClickListener()
if the user tap on the info window
Solution 3:[3]
Create marker object and call marker.hideInfoWindow(); look this
Marker marker = googleMap.addMarker(new MarkerOptions()
marker.hideInfoWindow();
Solution 4:[4]
you can easily not give it the title in the first place and voila!!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nanoc |
Solution 2 | Wilik |
Solution 3 | Mohit Suthar |
Solution 4 | kamal douma |