コード例 #1
0
ファイル: Parish.java プロジェクト: Coccoonx/relieferd
 Parish[] getAllParish() {
   return Parish.values();
 }
コード例 #2
0
ファイル: GoActivity.java プロジェクト: Coccoonx/relieferd
  @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();
    }
  }