private void setUpMapView() {

    mMapView = (ParkMapView) findViewById(R.id.themap);
    mMapView.setBuiltInZoomControls(true);
    mMapView.setSatellite(false);
    // Add listeners
    mMapView.setOnChangeListener(new MapViewChangeListener());

    //		itemizedOverlays.setOnTapListener(new MapViewTapListener());
    Log.e(ParkingConstants.TAG, "Map listenr set!");
  }
 @SuppressWarnings("unchecked")
 public void run() {
   // Notify
   Toast.makeText(FindParkingMapActivity.this, "Map Pan", Toast.LENGTH_SHORT).show();
   if (!mMapView.getOverlays().isEmpty()) {
     // mMapView.getOverlays().remove(itemizedOverlays);
     // mMapView.getOverlays().remove(itemizedOverlays2);
     // mMapView.getOverlays().remove(itemizedOverlays3);
     mMapView.getOverlays().clear();
     if (myLocOverlay != null) mMapView.getOverlays().add(myLocOverlay);
     mMapView.postInvalidate();
   }
   showDialog(0);
 }
  private void overlayTappableParkingSpots() {

    String address = "No Associated Address";
    GeoPoint pSpotGeoPoint = null;
    OverlayItem overlayitem = null;
    String sPpotInfo = "No Info Available";
    Drawable drawable =
        myContext.getResources().getDrawable(R.drawable.blue_markerp); // map_marker_black);
    itemizedOverlays = new MapOverLays(drawable, myContext);
    Drawable drawable2 =
        myContext.getResources().getDrawable(R.drawable.darkgreen_markerp); // map_marker_black);
    itemizedOverlays2 = new MapOverLays(drawable2, myContext);

    Drawable drawable3 =
        myContext.getResources().getDrawable(R.drawable.red_markerp); // map_marker_black);
    itemizedOverlays3 = new MapOverLays(drawable3, myContext);

    int dataPoints = FindParkingTabs.parkingLocations.size();
    int displayPoints;
    if (FindParkingTabs.zoomlevel <= 14) displayPoints = 30;
    else if (FindParkingTabs.zoomlevel == 15 || FindParkingTabs.zoomlevel == 16)
      displayPoints = dataPoints;
    else displayPoints = dataPoints;
    int count = 1;
    Log.v(TAG, "Parked item size" + FindParkingTabs.parkingLocations.size());
    for (ParkingLocationDataEntry parkingSpot : FindParkingTabs.parkingLocations) {

      if (count >= displayPoints) break;
      pSpotGeoPoint = parkingSpot.getGeoPoint();
      address = "empty"; // convertPointToLocation(pSpotGeoPoint);
      sPpotInfo = LocationUtility.convertObjToString(parkingSpot);
      overlayitem = new OverlayItem(pSpotGeoPoint, address, sPpotInfo);
      // Log.v(TAG, "Spot type: " + parkingSpot.getType());
      if (parkingSpot.getType().contains("MultiMeterPost"))
        itemizedOverlays2.addOverlay(overlayitem);
      else if (parkingSpot.getType().contains("OffStreetParking"))
        itemizedOverlays3.addOverlay(overlayitem);
      else itemizedOverlays.addOverlay(overlayitem);

      count++;
    }
    itemizedOverlays.addDone();
    itemizedOverlays2.addDone();
    itemizedOverlays3.addDone();
    mMapView.getOverlays().add(itemizedOverlays);
    mMapView.getOverlays().add(itemizedOverlays2);
    mMapView.getOverlays().add(itemizedOverlays3);
    mMapView.postInvalidate();
  }
  @SuppressWarnings("unchecked")
  private void overlayParkingSpots() {
    Log.v(TAG, "overlayParkingSpots");
    if (staticDowntownMapPopulated == false) {
      Log.v(TAG, "populate static map first time");
      List<ParkingLocationDataEntry> nLocList = new LinkedList<ParkingLocationDataEntry>();
      ParkingLocationDataEntry nLoc = new ParkingLocationDataEntry();
      nLoc.setLatitude((float) ParkingConstants.DOWNTOWN_FIXED_LATITUDE);
      nLoc.setLongitude((float) ParkingConstants.DOWNTOWN_FIXED_LONGITUDE);

      nLocList.add(nLoc);

      /** Center map to downtown */
      GeoPoint gp =
          new GeoPoint((int) (nLoc.getLatitude() * 1E6), (int) (nLoc.getLongitude() * 1E6));

      /** Dont Center the map to downtown for current location * */
      if (true == locationFixedToDowntown) {
        mMapView.getController().setCenter(gp);
        mMapView.getController().animateTo(gp);
      }

      staticDowntownMapPopulated = true;
      mGetLocationList = new GetLocationList(getBaseContext(), mMapView, this);
      mGetLocationList.execute(nLocList);

    } else {
      Log.v(TAG, "populate map everyothertime" + staticDowntownMapPopulated);

      GeoPoint mapCenter = mMapView.getMapCenter();

      if (mGetLocationList == null) {

        List<ParkingLocationDataEntry> nLocList = new LinkedList<ParkingLocationDataEntry>();
        ParkingLocationDataEntry nLoc = new ParkingLocationDataEntry();
        nLoc.setLatitude((float) ((float) mapCenter.getLatitudeE6() / 1E6));
        nLoc.setLongitude((float) ((float) mapCenter.getLongitudeE6() / 1E6));
        nLocList.add(nLoc);
        mGetLocationList =
            new GetLocationList(getBaseContext(), mMapView, FindParkingMapActivity.this);
        mGetLocationList.execute(nLocList);
      } else Log.v(TAG, "Async task still running");
    }
  }
  private void updateCurrentUserLocation() {

    Toast.makeText(getApplicationContext(), "Updating Location...", Toast.LENGTH_LONG).show();

    myLocOverlay = new DerivedMyLocationOverlay(this, mMapView);
    // Gives the blue 'google' location marker

    mMapView.getOverlays().add(myLocOverlay);
    myLocOverlay.runOnFirstFix(
        new Runnable() {
          public void run() {
            mMapView.getController().animateTo(myLocOverlay.getMyLocation());
            mMapView.postInvalidate();
          }
        });
  }
 public void run() {
   // Notify
   FindParkingTabs.zoomlevel = mMapView.getZoomLevel();
   Log.v(TAG, "Map Zoom level: " + mMapView.getZoomLevel());
   Toast.makeText(FindParkingMapActivity.this, "Map Zoom", Toast.LENGTH_SHORT).show();
   if (!mMapView.getOverlays().isEmpty()) {
     // mMapView.getOverlays().remove(itemizedOverlays);
     // mMapView.getOverlays().remove(itemizedOverlays2);
     // mMapView.getOverlays().remove(itemizedOverlays3);
     mMapView.getOverlays().clear();
     if (myLocOverlay != null) mMapView.getOverlays().add(myLocOverlay);
     mMapView.postInvalidate();
     /** Redisplay the spots based on zoom level * */
     overlayTappableParkingSpots();
   }
 }
 public void run() {
   // Notify
   FindParkingTabs.zoomlevel = mMapView.getZoomLevel();
   Toast.makeText(FindParkingMapActivity.this, "Map Zoom + Pan", Toast.LENGTH_SHORT).show();
 }
  private void setUpMapController() {

    mapController = mMapView.getController();
    mapController.setZoom(ParkingConstants.DEFAULT_ZOOM_LEVEL); // Zoom 1 is world view
  }