package com.meyersj.locationsurvey.app;

import android.util.Log;

import com.mapbox.mapboxsdk.api.ILatLng;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.overlay.ItemizedIconOverlay;
import com.mapbox.mapboxsdk.overlay.Marker;
import com.mapbox.mapboxsdk.views.MapView;
import com.mapbox.mapboxsdk.views.MapViewListener;

import java.util.ArrayList;

/**
 * Created by jeff on 05/05/14.
 */
public class mMapViewListener implements MapViewListener {
    String TAG = "MyMapViewListener";

    @Override
    public void onShowMarker(MapView mapView, Marker marker) {

    }

    @Override
    public void onHidemarker(MapView mapView, Marker marker) {

    }

    @Override
    public void onTapMarker(MapView mapView, Marker marker) {
        Log.d(TAG, "marker was tapped");
    }

    @Override
    public void onLongPressMarker(MapView mapView, Marker marker) {

    }

    @Override
    public void onTapMap(MapView mapView, ILatLng iLatLng) {

    }

    @Override
    public void onLongPressMap(MapView mapView, ILatLng iLatLng) {
        LatLng latLng = new LatLng(iLatLng.getLatitude(), iLatLng.getLongitude());
        ArrayList<ItemizedIconOverlay> overlays = mapView.getItemizedOverlays();
        ItemizedIconOverlay locOverlay;

        if (!overlays.isEmpty()) {
            locOverlay = overlays.get(0);
            locOverlay.removeAllItems();
            Marker m = new Marker("test", null, latLng);
            m.addTo(mapView);
            locOverlay.addItem(m);
            mapView.invalidate();
            //mapView.setCenter(iLatLng);
        }
        //LocationType locationType = new LocationType(mapView, latLng);
        //locationType.setLocationType();

    }



}

package com.meyersj.locationsurvey.app;

import android.util.Log;

import com.mapbox.mapboxsdk.api.ILatLng;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.overlay.ItemizedIconOverlay;
import com.mapbox.mapboxsdk.overlay.Marker;
import com.mapbox.mapboxsdk.views.MapView;
import com.mapbox.mapboxsdk.views.MapViewListener;

import java.util.ArrayList;

/**
 * Created by jeff on 05/05/14.
 */
public class mMapViewListener implements MapViewListener {
    String TAG = "MyMapViewListener";

    @Override
    public void onShowMarker(MapView mapView, Marker marker) {

    }

    @Override
    public void onHidemarker(MapView mapView, Marker marker) {

    }

    @Override
    public void onTapMarker(MapView mapView, Marker marker) {
        Log.d(TAG, "marker was tapped");
    }

    @Override
    public void onLongPressMarker(MapView mapView, Marker marker) {

    }

    @Override
    public void onTapMap(MapView mapView, ILatLng iLatLng) {
        LatLng latLng = new LatLng(iLatLng.getLatitude(), iLatLng.getLongitude());
        ArrayList<ItemizedIconOverlay> overlays = mapView.getItemizedOverlays();
        ItemizedIconOverlay locOverlay;

        if (!overlays.isEmpty()) {
            locOverlay = overlays.get(0);
            locOverlay.removeAllItems();
            Marker m = new Marker("test", null, latLng);
            m.addTo(mapView);
            locOverlay.addItem(m);
            mapView.invalidate();
            //mapView.setCenter(iLatLng);
        }
        //LocationType locationType = new LocationType(mapView, latLng);
        //locationType.setLocationType();
    }

    @Override
    public void onLongPressMap(MapView mapView, ILatLng iLatLng) {
        /*
        LatLng latLng = new LatLng(iLatLng.getLatitude(), iLatLng.getLongitude());
        ArrayList<ItemizedIconOverlay> overlays = mapView.getItemizedOverlays();
        ItemizedIconOverlay locOverlay;

        if (!overlays.isEmpty()) {
            locOverlay = overlays.get(0);
            locOverlay.removeAllItems();
            Marker m = new Marker("test", null, latLng);
            m.addTo(mapView);
            locOverlay.addItem(m);
            mapView.invalidate();
            //mapView.setCenter(iLatLng);
        }
        //LocationType locationType = new LocationType(mapView, latLng);
        //locationType.setLocationType();
        */

    }



}

make add marker on pick location single tap