title: Customize My Location Overlay Update Times
body: <p>I am trying to implement the <a href="http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MyLocationOverlay.html" rel="nofollow noreferrer"><code>MyLocationOverlay</code></a> class from google maps. However, when I try and use my own locationManager -- I cannot get the overlay to acutally draw on the map. I am wondering if I am doing something wrong.</p>
  
  <p>I don't want to call the super method(enbaleMyLocation) of the MyLocationOverlay class because that request updates from the locationManager way too quickly and will eat my battery alive.</p>
  
  <p>Here is my code: </p>
  
  <pre><code>private class CenterOverlay extends MyLocationOverlay {
  
      private Context mContext;
      private LocationManager mLocManager;
  
      public CenterOverlay(Context context, MapView mapView) {
          super(context, mapView);
          this.mContext = context;
  
      }
  
      @Override
      public void onLocationChanged(Location location) {
          super.onLocationChanged(location);
          try {
              doExternalCenterOverlayTask(location);
          } catch (JSONException e) {
              e.printStackTrace();
              ErrorHandler.serviceException(mContext);
          } catch (IOException e) {
              e.printStackTrace();
              ErrorHandler.IOException(mContext);
          } catch (ServiceException e) {
              e.printStackTrace();
              ErrorHandler.serviceException(mContext);
          }
      }
  
      @Override
      public boolean enableMyLocation() {
          mLocManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
          mLocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 50, this);
          mLocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5000, 25, this);
  
          return mLocManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
                  || mLocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
      }
  
      @Override
      public void disableMyLocation() {
          super.disableMyLocation();
          mLocManager.removeUpdates(this);
      }
  
      @Override
      public void onProviderDisabled(String provider) {
          super.onProviderDisabled(provider);
          ViewAdapter.createStandardAlertDialog(mContext,
                  "Your location provider has been disabled, please re-enable it.");
      }
  
      @Override
      public void onProviderEnabled(String provider) {
          super.onProviderEnabled(provider);
      }
  
      @Override
      public void onStatusChanged(String provider, int status, Bundle extras) {
          super.onStatusChanged(provider, status, extras);
          if (status == 0) {
              ViewAdapter.showLongToast(mContext, "Location is not available at this time");
          } else if (status == 1) {
              //Trying to connect
          } else if (status == 2) {
              // Available
          }
  
      }
  
  }
  </code></pre>