Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : If markers are overlapping each other on the map, then the click event is fired for the last hidden one

In our application, a lot of markers are drawn in different locations and in certain cases at a certain zoom level, markers overlap each other. So when I click on the marker, I expect the top marker's onMarkerClick to be fired but instead it is fired for the last hidden marker i-e the last marker, with no markers behind it.

What do you suggest I do? Also, I have no info windows, therefore I return true from onMarkerClick method.

like image 302
Khalil Avatar asked Feb 07 '14 06:02

Khalil


People also ask

How do I drag a marker on Google Maps Android?

Long press the marker to enable dragging. When you take your finger off the screen, the marker will remain in that position. Markers are not draggable by default. You must explicitly set the marker to be draggable either with MarkerOptions.

Which function should you use if you want to add markers to display a specific location on a map that you draw?

Try Sample // To add the marker to the map, call setMap(); marker. setMap(map);

How will you add marker on map in android?

For adding a custom marker to Google Maps navigate to the app > res > drawable > Right-Click on it > New > Vector Assets and select the icon which we have to show on your Map. You can change the color according to our requirements. After creating this icon now we will move towards adding this marker to our Map.


1 Answers

I found the solution here: https://github.com/googlemaps/android-maps-utils/issues/26

mGoogleMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter()
    {
        @Override
        public View getInfoWindow(Marker marker)
        {
            // Empty info window.
            return new View(getApplicationContext());
        }

        @Override
        public View getInfoContents(Marker marker)
        {
            return null;
        }
    });
like image 180
Jiajun Avatar answered Oct 17 '22 20:10

Jiajun