Esempio n. 1
0
 Parish[] getAllParish() {
   return Parish.values();
 }
Esempio n. 2
0
  @Override
  public void onConnected(Bundle bundle) {
    Location l = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
    if (l != null) {
      mCurrentLatLn = new LatLng(l.getLatitude(), l.getLongitude());
      UIUtils.moveCameraTo(mGoogleMap, mCurrentLatLn, this);
    }

    if (mCurrentLatLn != null) {
      final Parish mostClosed = CoreUtils.getMinLatLng(mCurrentLatLn);

      if (mostClosed != null) {
        // Creating MarkerOptions
        MarkerOptions options = new MarkerOptions();

        // Setting the position of the marker
        options.position(mostClosed.getLatLng());
        options.snippet(mostClosed.getDisplayName());
        options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
        mGoogleMap.addMarker(options);

        // Getting URL to the Google Directions API
        String url = getDirectionsUrl(mCurrentLatLn, mostClosed.getLatLng());

        DownloadTask downloadTask = new DownloadTask();

        // Start downloading json data from Google Directions API
        downloadTask.execute(url);
      }
      progressDialog.dismiss();
      showGroup(mCurrentLatLn, mostClosed.getLatLng());

      btnDraw.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              String uri =
                  String.format(
                      Locale.ENGLISH,
                      "http://maps.google.com/maps?saddr=%f,%f(%s)&daddr=%f,%f (%s)",
                      mCurrentLatLn.latitude,
                      mCurrentLatLn.longitude,
                      "My position",
                      mostClosed.getLatLng().latitude,
                      mostClosed.getLatLng().longitude,
                      "" + mostClosed.getDisplayName());
              Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
              intent.setClassName(
                  "com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
              startActivity(intent);
            }
          });
      //            btnDraw.setVisibility(View.VISIBLE);

    } else {
      progressDialog.dismiss();
      Toast.makeText(GoActivity.this, "Please enable your location service.", Toast.LENGTH_SHORT)
          .show();
    }
  }