title: Android-Google Maps Satellite toggle
body: <p>I want to add button which will toggle between normal and satellite view in the map view and I keep getting a <code>the application has stopped unexpectedly</code> error</p>
  
  <pre><code>public class NewMapsActivity extends MapActivity 
  {    
      private MapView myMapView;
  
      @Override
          protected void onCreate(Bundle icicle) 
      {
          super.onCreate(icicle);
          setContentView(R.layout.main);
  
          MapView myMapView = (MapView) findViewById(R.id.mapview);
  
          Button mySatelliteButton = (Button)findViewById(R.id.c_button);
          mySatelliteButton.setOnClickListener(new View.OnClickListener()
          {
             public void onClick(View v)
              {
                  SetSatellite();
              }
          });
       myMapView.setBuiltInZoomControls(true);
       }
  
      private void SetSatellite()
          {
              if ( myMapView.isSatellite() )
                  myMapView.setSatellite(false);
              else 
                  myMapView.setSatellite(true);
          }
  
      @Override
          protected boolean isRouteDisplayed() 
       {
              return false;
       }
  }
  </code></pre>