Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 4th, 2013  |  syntax: None  |  size: 1.06 KB  |  views: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. @ContentView(R.layout.map)
  2. public class MyMapActivity extends RoboMapActivity {
  3.  
  4. @InjectView(R.id.map)
  5. private MapView map;
  6.  
  7. private List<Overlay> mapOverlays;
  8. private MyLocationOverlay compass;
  9. private TestOverlay testOverlay;
  10.  
  11. @Override
  12. protected void onCreate(Bundle savedInstanceState) {
  13.     super.onCreate(savedInstanceState);
  14.  
  15.     map.setBuiltInZoomControls(true);
  16.     mapOverlays = map.getOverlays();
  17.     compass = new MyLocationOverlay(this, map);
  18.     testOverlay = new TestOverlay();
  19. }
  20.  
  21. @Override
  22. protected void onResume() {
  23.     super.onResume();
  24.     compass.enableCompass();
  25.     refreshMap();
  26. }
  27.  
  28. private void refreshMap() {
  29.     mapOverlays.clear();
  30.     mapOverlays.add(testOverlay);
  31. }
  32.  
  33. @Override
  34. protected void onPause() {
  35.     compass.disableCompass();
  36.     super.onPause();
  37. }
  38.  
  39. @Override
  40. protected boolean isRouteDisplayed() {
  41.     return false;
  42. }
  43. }
  44.        
  45. public class TestOverlay extends Overlay {
  46.  
  47. @Override
  48. public void draw(Canvas arg0, MapView arg1, boolean arg2) {
  49.     System.out.println("drawing...");
  50.     super.draw(arg0, arg1, arg2);
  51. }
  52. }
  53.        
  54. // compass.enableCompass();
clone this paste RAW Paste Data