OnTouchEvent in a Overlay

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

OnTouchEvent in a Overlay

Postby danthorpe » Tue Mar 16, 2010 12:37 pm

Hi, newbie here ...

I have a MapView with a MapItemizedOverlay, like this :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
  3.  
  4. itemizedOverlay = new MapItemizedOverlay(drawable);
  5.  
  6.  
  7.  
  8. OverlayItem overlayitem = new OverlayItem(p, "", "");
  9.  
  10.  
  11.  
  12. itemizedOverlay.addOverlay(overlayitem);        
  13.  
  14. mapOverlays.add(itemizedOverlay);
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


I want to know when the user touches the AndroiMarker, so I can show some info about that specific place. How do I do that ?

Tks in advance!
danthorpe
Freshman
Freshman
 
Posts: 2
Joined: Tue Sep 22, 2009 4:18 pm

Top

Postby mistajase » Thu Mar 18, 2010 2:00 pm

Hi I've done something similar, I think if you change

Code: Select all
OverlayItem overlayitem = new OverlayItem(p, "", "");


to

Code: Select all
OverlayItem overlayitem = new OverlayItem(p, "Hola, danthorpe!", "I'm here");


and add

Code: Select all
@Override
protected boolean onTap(int index) {
  OverlayItem item = mOverlays.get(index);
  AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
  dialog.setTitle(item.getTitle());
  dialog.setMessage(item.getSnippet())
  dialog.show();
  return true;
}


If you need help check out

http://developer.android.com/intl/de/re ... pview.html

as its shows how to do something like you want.
mistajase
Junior Developer
Junior Developer
 
Posts: 20
Joined: Thu Nov 26, 2009 4:28 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests