Detecting click event on overlay item in android map (V2)

1.5k Views Asked by At

Hi I am developing small android application in which I am using android map V2. I include ground overlay item in my map. So I want to detect click on overlay item. I added overlay item in following manner.

 LatLng NEWARK = new LatLng(0, 0);

        GroundOverlayOptions newarkMap = new GroundOverlayOptions()
                //.image(BitmapDescriptorFactory.fromResource(R.drawable.img)
                  .image(BitmapDescriptorFactory.fromBitmap(createDrawableFromView(this, markerView)))
                .position(NEWARK, 860000f, 650000f);
        GroundOverlay imageOverlay = googleMap.addGroundOverlay(newarkMap);

So I want to do something when user clicks on this overlay item. Need Some help. Thank you.

2

There are 2 best solutions below

0
On

There are no OnClickListeners other than for Markers.

You may want to work with OnMapClickListener, where you get LatLng and do the check for distance yourself.

0
On

You can listen it via googleMap.setOnGroundOverlayClickListener()