Ejemplo n.º 1
0
  private void drawImageOverMap() {

    // BitmapFactory.Options options = new BitmapFactory.Options();
    // options.inSampleSize = 2;
    // Bitmap bitmap = BitmapFactory.decodeResource(this.getResources(),
    // R.drawable.trails_nomarkup,options);

    Bitmap bitmap = DisplayManager.getInstance().getCanvasBitmap();

    image = BitmapDescriptorFactory.fromBitmap(bitmap);
    LatLngBounds bounds = new LatLngBounds(southwest, northeast);

    mGroundOverlay =
        googleMap.addGroundOverlay(
            new GroundOverlayOptions().image(image).transparency(0).positionFromBounds(bounds));
  }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // set layout for activity
    setContentView(R.layout.activity_google_maps);

    // Getting reference to the google map fragment
    MapFragment fm = (MapFragment) getFragmentManager().findFragmentById(R.id.googlemap);

    // Getting GoogleMap object from the fragment
    googleMap = fm.getMap();

    // googleMap is a GoogleMap object
    googleMap.setMyLocationEnabled(true);
    googleMap.getUiSettings().setMyLocationButtonEnabled(true);
    googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);

    // zoom to TCS coordinates on start
    LatLng myLocation = new LatLng(39.15, -84.244493);

    googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(myLocation, 16));

    // check for GPS enabled
    final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
      showEnableGPSDialog();
    }

    // set listener for if My Location button is clicked to check for GPS again
    final Context context = this;
    googleMap.setOnMyLocationButtonClickListener(
        new GoogleMap.OnMyLocationButtonClickListener() {
          @Override
          public boolean onMyLocationButtonClick() {
            LocationManager mgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            if (!mgr.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
              // Toast.makeText(context, "GPS is disabled!", Toast.LENGTH_SHORT).show();
              showEnableGPSDialog();
            }
            return false;
          }
        });

    // draw trails map over Google Maps
    drawImageOverMap();

    // initialize transparency adjuster bar for dev mode
    mTransparencyBar = (SeekBar) findViewById(R.id.transparencySeekBar);
    mTransparencyBar.setMax(TRANSPARENCY_MAX);
    mTransparencyBar.setProgress(0);

    mTransparencyBar.setOnSeekBarChangeListener(this);

    // only show transparency bar if in dev mode
    if (DisplayManager.getInstance().getInDevMode()) {
      mTransparencyBar.setVisibility(View.VISIBLE);
    } else {
      mTransparencyBar.setVisibility(View.GONE);
    }
  }