Code example for GoogleMap

Methods: addPolylineanimateCameraclear

0
    CameraPosition cameraPosition = new CameraPosition.Builder().target(latLang) // Sets the center of the map to Mountain View
                                                                .zoom(17)
                                                                // Sets the zoom 
                                                                .build();
    // Creates a CameraPosition from the builder 
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
  } 
 
  /** 
   * Adds a marker to the map given a location 
   *  
   * @param location 
   */ 
  private void addMarker(Location location) {
    final LatLng test = new LatLng(location.getLatitude(), location.getLongitude());
    Marker melbourne = mMap.addMarker(new MarkerOptions().position(test).title("Test").snippet("snippet"));
  } 
 
  /** 
   * Adds a point to the polyline drawn on the map 
   *  
   * @param location 
   */ 
  private void addPointToPolyline(Location location) {
    //Create a new LatLng object from the given location 
    LatLng newLoc = new LatLng(location.getLatitude(), location.getLongitude());
    // Instantiates a new Polyline object and adds points to define a rectangle 
    if (poly == null) {
      poly = new PolylineOptions().width(40).color(Color.RED).geodesic(true);
    } 
    poly.add(newLoc);
    mMap.clear();
    mMap.addPolyline(poly);
    updateCamera(newLoc);
  } 
 
  @Override 
  public void onNewTracking(Location loc) {
Contextual code suggestions in your IDE  Get Codota for Java