Detecting Touch, clicks or taps on the Device

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

Detecting Touch, clicks or taps on the Device

Postby insanomania911 » Tue Jun 09, 2009 5:00 pm

I tried many different codes a codes and, I can't seem to make this work.

All I need is to click on my map and have some sort of a listener trigger like a popup window,dialog or Toast giving the user the long/lat. It just doesn't work. I have my MapView created in my xml main layout fle where I set android:clickable="true" and android:enabled="true"

Also I have the following code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. class MapOverlay extends com.google.android.maps.Overlay
  2.  
  3. {      
  4.  
  5.  
  6.  
  7. @Override
  8.  
  9. public boolean onTouchEvent(MotionEvent event, MapView mapView)
  10.  
  11. {
  12.  
  13.  
  14.  
  15. System.out.println("reached here 2 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  16.  
  17. //---when user lifts his finger---
  18.  
  19. if (event.getAction() == MotionEvent.ACTION_UP) {
  20.  
  21. GeoPoint p = mapView.getProjection().fromPixels(
  22.  
  23. (int) event.getX(),
  24.  
  25. (int) event.getY());
  26.  
  27. Toast.makeText(getBaseContext(),
  28.  
  29. p.getLatitudeE6() / 1E6 + "," +
  30.  
  31. p.getLongitudeE6() /1E6 ,
  32.  
  33. Toast.LENGTH_SHORT).show();
  34.  
  35.  
  36.  
  37. System.out.println("Touched this loc: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+p);
  38.  
  39. }
  40.  
  41. return false;
  42.  
  43. }
  44.  
  45.  
  46.  
  47.  
  48.  
  49. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4



what am I doing wrong? because I am not getting anything.

thanks.
insanomania911
Junior Developer
Junior Developer
 
Posts: 12
Joined: Tue Jun 09, 2009 4:53 pm

Top

Postby burujo » Sun Aug 16, 2009 6:26 pm

I'm not sure, but I think that you need to use the setOnTouchListener from mapView
burujo
Freshman
Freshman
 
Posts: 4
Joined: Thu Mar 26, 2009 1:32 am

Postby sandis84 » Tue Aug 18, 2009 2:14 pm

please, this part of the forum is for tutorials.
sandis84
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Fri Aug 07, 2009 3:54 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests