I have implemented google maps in my application. I have written my own overlay class extending ItemizedOverlay to add overlays. Using the same overlay class, I also add an overlay to show my current location on the map.
The onTouchEvent of this overlay class is used to determine where the touch was made and be able to move the overlay object to anywhere on the map. This however, is causing some problem. The pointer to my current location also becomes movable. I want to fix this current location pointer.
For this, i am creating a new class MyNewLocationOverLay which extends my previously created custom overlay. My plan is to override the onTouchEvent method and return the super.onTouchEvent in case of touching on other overlays and to return true on touch of mylocation overlay. How do I find out what overlay was clicked. I tried:
public class myOverlayclass extends OverLayClass {
public myOverlayclass(Drawable marker) {
super(marker);
// TODO Auto-generated constructor stub
}
public boolean onTouchEvent(MotionEvent motionEvent, MapView mapView) {
System.out.println("The overlays are*************"+mapView.getOverlays()); //this lists the overlays
return super.onTouchEvent(motionEvent, mapView);
}
}
I need to compare this to find which overlay was touched. How do I compare overlays.
if (mapView.getOverlays().contains(mYLocationOverLay))
does not seem to work.
Inside the onTouchEvent method, I performed a hit test to find out which overlay was touched. And compared that to myLocationGeoPoint.
Hope it helps someone!