title: Add marker on long press in Google Maps API v3
body: <p>How to implement adding a marker on long press in Google Maps API v3 for android? There are answers about this in Stack Overflow itself but they are for Google Maps API v2.</p>
  
  <pre><code>public class advertiserMap extends FragmentActivity implements OnMapReadyCallback {
  
  private GoogleMap mMap;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_advertiser_map);
      // Obtain the SupportMapFragment and get notified when the map is ready to be used.
      SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
              .findFragmentById(R.id.map);
      mapFragment.getMapAsync(this);
  }
  
  //for searching for a location
  public void onMapSearch(View view) {
      EditText locationSearch = (EditText) findViewById(R.id.editText);
      String location = locationSearch.getText().toString();
      List&lt;Address&gt; addressList = null;
  
      if (location != null || !location.equals("")) {
          Geocoder geocoder = new Geocoder(this);
          try {
              addressList = geocoder.getFromLocationName(location, 1);
  
          } catch (IOException e) {
              e.printStackTrace();
          }
          Address address = addressList.get(0);
          LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
          mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
      }
  }
  
  @Override
  public void onMapReady(GoogleMap googleMap) {
      mMap = googleMap;
  
      // Add a marker in Sydney and move the camera
      LatLng sydney = new LatLng(-34, 151);
      mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
      mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
  }
  </code></pre>
  
  <p>}</p>