@Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   byte[] data = getIntent().getExtras().getByteArray(SHOW_ROUTE_EXTRA_PROTO);
   if (data == null) {
     Log.v(TAG, "Intent Data is null");
     finish();
   }
   try {
     route = Route.parseFrom(data);
   } catch (InvalidProtocolBufferException e) {
     Log.v(TAG, "Intent Data does not parse");
     e.printStackTrace();
     finish();
   }
   storage = new PlaceStorage(this);
   // Ug, this is unfortunate.
   if (route.getRoutePointCount() == 0) {
     place = Place.newBuilder().setLatitude(0).setLongitude(0).build();
   } else {
     place = storage.getPlaceForRoute(RouteUtils.getLastRoutePoint(route));
   }
   setTitle(RouteCursorAdapter.getRouteTime(route));
   setContentView(R.layout.activity_show_route_map);
   RouteCursorAdapter.setupListView(findViewById(R.id.routeDetails), route, storage, null);
   map = ((MapFragment) getFragmentManager().findFragmentById(R.id.bigMap)).getMap();
   map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
   Point size = new Point();
   getWindowManager().getDefaultDisplay().getSize(size);
   CameraUpdate cameraUpdate =
       CameraUpdateFactory.newLatLngBounds(getBounds(), size.x, size.y, 50);
   map.moveCamera(cameraUpdate);
   showRoute();
 }
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
      // Use the Builder class for convenient dialog construction
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      View settingsView = activity.getLayoutInflater().inflate(R.layout.place_settings, null);
      builder.setTitle("Place Settings:");
      builder.setView(settingsView);
      final EditText view = (EditText) settingsView.findViewById(R.id.placeName);
      final CheckBox ignored = (CheckBox) settingsView.findViewById(R.id.ignorePlace);
      if (place != null) {
        view.setText(place.getName());
        ignored.setChecked(place.getIgnored());
      }
      builder.setNegativeButton(
          "Cancel",
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              dialog.dismiss();
            }
          });

      builder.setPositiveButton(
          "Save",
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              Place.Builder newPlace;
              if (place != null) {
                newPlace = Place.newBuilder(place);
              } else {
                newPlace = Place.newBuilder();
                newPlace.setTime(System.currentTimeMillis());
                RoutePoint routePoint = route.getRoutePoint(route.getRoutePointCount() - 1);
                newPlace.setLatitude(routePoint.getLatitude());
                newPlace.setLongitude(routePoint.getLongitude());
              }
              newPlace.setName(view.getText().toString());
              newPlace.setIgnored(ignored.isChecked());
              storage.savePlace(newPlace.build(), place != null);
              dialog.dismiss();
            }
          });

      return builder.create();
    }
 private void showRoute() {
   PolylineOptions rectOptions = new PolylineOptions();
   LatLng latLng = null;
   for (RoutePoint point : route.getRoutePointList()) {
     latLng = new LatLng(point.getLatitude(), point.getLongitude());
     rectOptions.add(latLng);
   }
   rectOptions.color(0xA00080FF);
   map.addPolyline(rectOptions);
   MarkerOptions endMarker = new MarkerOptions();
   endMarker.position(latLng);
   String label = place != null ? place.getName() : "Parking Spot";
   endMarker.title(label + " @ " + RouteCursorAdapter.getRouteTimeAgo(this, route));
   endMarker.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher));
   endMarker.anchor(0.5f, 0.5f);
   map.addMarker(endMarker);
 }