-
Notifications
You must be signed in to change notification settings - Fork 982
/
MapEventsOverlay.java
55 lines (45 loc) · 1.53 KB
/
MapEventsOverlay.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package org.osmdroid.views.overlay;
import android.content.Context;
import android.view.MotionEvent;
import org.osmdroid.events.MapEventsReceiver;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import org.osmdroid.views.Projection;
/**
* Empty overlay than can be used to detect events on the map,
* and to throw them to a MapEventsReceiver.
*
* @author M.Kergall
* @see MapEventsReceiver
*/
public class MapEventsOverlay extends Overlay {
private MapEventsReceiver mReceiver;
/**
* Use {@link #MapEventsOverlay(MapEventsReceiver)} instead
*/
@Deprecated
public MapEventsOverlay(Context ctx, MapEventsReceiver receiver) {
this(receiver);
}
/**
* @param receiver the object that will receive/handle the events.
* It must implement MapEventsReceiver interface.
*/
public MapEventsOverlay(MapEventsReceiver receiver) {
super();
mReceiver = receiver;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e, MapView mapView) {
Projection proj = mapView.getProjection();
GeoPoint p = (GeoPoint) proj.fromPixels((int) e.getX(), (int) e.getY());
return mReceiver.singleTapConfirmedHelper(p);
}
@Override
public boolean onLongPress(MotionEvent e, MapView mapView) {
Projection proj = mapView.getProjection();
GeoPoint p = (GeoPoint) proj.fromPixels((int) e.getX(), (int) e.getY());
//throw event to the receiver:
return mReceiver.longPressHelper(p);
}
}