OnTouchEvent, OnTap, onTrackballEvent not working??

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

OnTouchEvent, OnTap, onTrackballEvent not working??

Postby rdormer » Thu Feb 05, 2009 5:01 pm

I have an overlay subclass with these members overridden in it, but when I add the overlay to the map, it does not seem to receive any of these events. Do I need to enable them somehow?
rdormer
Freshman
Freshman
 
Posts: 8
Joined: Tue Dec 16, 2008 12:26 am

Top

Postby dmc1024 » Thu Feb 05, 2009 6:28 pm

nope, i'm working with them right now. perhaps post some code so i can help you take a looka t it.
dmc1024
Freshman
Freshman
 
Posts: 8
Joined: Sat Jan 24, 2009 8:27 am

Postby rdormer » Thu Feb 05, 2009 6:52 pm

I have gotten the onTouchEvent method to work now by calling setClickable, but onTapEvent and onTrackballEvent are still not working.


public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.result_detail);

String mapKey = getString(R.string.map_key);
MapView mapper = new MapView(this, mapKey);
_mapResults = MapShim.mostRecentSearch();

RelativeLayout container = (RelativeLayout) findViewById(R.id.InnerLayout);
container.addView(mapper);

mapper.setClickable(true);
addOverlays(mapper);

int mapLat = (int) (_mapResults.standingLatitude() * FLOAT_MULTIPLIER);
int mapLon = (int) (_mapResults.standingLongitude() * FLOAT_MULTIPLIER);
GeoPoint mapCenter = new GeoPoint(mapLat, mapLon);
mapper.getController().setCenter(mapCenter);
mapper.getController().setZoom(15);

ZoomControls zoomControls = (ZoomControls) mapper.getZoomControls();
zoomControls.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
mapper.addView(zoomControls);
mapper.displayZoomControls(true);
}

public boolean isRouteDisplayed() {
return false;
}

private void addOverlays(MapView mv) {

List<Overlay> olist = mv.getOverlays();
olist.add(new MapHandler());

MyLocationOverlay mlo = new MyLocationOverlay(this, mv);
mlo.enableMyLocation();

olist.add(mlo);
}

private class MapHandler extends Overlay {

public boolean onTouchEvent(MotionEvent e, MapView mapView) {


return true;
}

public boolean onTrackballEvent(MotionEvent event, MapView mapView) {

return true;
}

public boolean onTap(GeoPoint p, MapView mapView) {

return true;
}
rdormer
Freshman
Freshman
 
Posts: 8
Joined: Tue Dec 16, 2008 12:26 am

Postby dmc1024 » Thu Feb 05, 2009 7:00 pm

this shouldn't be it, but try "setEnabled" ?
i added my mapView via xml, and i have

<com.google.android.maps.MapView
android:id="@+id/mapview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="your key" />

try that?
(btw in case you didn't nkow, there is a class called itemizedoverlay, which is a list of overlays)
dmc1024
Freshman
Freshman
 
Posts: 8
Joined: Sat Jan 24, 2009 8:27 am

Postby rdormer » Thu Feb 05, 2009 9:54 pm

Tried this, to no avail :(
rdormer
Freshman
Freshman
 
Posts: 8
Joined: Tue Dec 16, 2008 12:26 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests