Get a MapActivity from a MapView

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

Get a MapActivity from a MapView

Postby nono35 » Wed Jul 23, 2008 9:39 am

Hi,

I would know how to get the current Activity ?
I have a MapActivity which displays a MapView which calls a method which extends Overlay, and I would get the MapActivity in the MapView and in the Overlay.

Thanks for reply
nono35
Freshman
Freshman
 
Posts: 4
Joined: Mon Jul 21, 2008 4:40 pm

Top

Postby plusminus » Wed Jul 23, 2008 7:27 pm

Hello nono,

I use the MapActivity (here DDMap, which extends MapActivity) in my Overlay, by passing it to the Constructor of the Overlay, like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public MyMapDrivingDirectionsOverlay(final DDMap aMapAct, final UnitSystem aUS) {
  2.  
  3.    //...
  4.  
  5. }
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


where adding the Overlay works like this (inside the DDMap-Class):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 /* Add a new instance of our fancy Overlay-Class to the MapView. */
  2.  
  3.                 this.mOverlayController.add(new MyMapDrivingDirectionsOverlay(this, this.mUnitSystem), true);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Hope I could help you.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby nono35 » Thu Jul 24, 2008 5:05 pm

thanks for your reply plusminus,

but I don't call the constructor of the overlay in my MapActivity, I call this in my MapView, so I can retrieve the MapView in my Overlay, but I want to retrieve my MapActivity in my MapView and in my Overlay...
and I can't pass my mapActivity to the constructor of my MapView because I don't use a constructor, I use setContentView() to call my mapView in my mapActivity like this :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class Map extends MapActivity {
  2.  
  3.        
  4.  
  5.         private MapLocationViewer mapView;
  6.  
  7.        
  8.  
  9.     public void onCreate(Bundle icicle) {
  10.  
  11.         super.onCreate(icicle);
  12.  
  13.         setContentView(R.layout.map);
  14.  
  15.         mapView = (MapLocationViewer)this.findViewById(R.id.map_location_viewer);
  16.  
  17. }
  18.  
  19. }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


have you a solution for that ?
nono35
Freshman
Freshman
 
Posts: 4
Joined: Mon Jul 21, 2008 4:40 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 1 guest