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();

    }



}

@@ -964,24 +964,669 @@
  iLatLng) %7B%0A
+        LatLng latLng = new LatLng(iLatLng.getLatitude(), iLatLng.getLongitude());%0A        ArrayList%3CItemizedIconOverlay%3E overlays = mapView.getItemizedOverlays();%0A        ItemizedIconOverlay locOverlay;%0A%0A        if (!overlays.isEmpty()) %7B%0A            locOverlay = overlays.get(0);%0A            locOverlay.removeAllItems();%0A            Marker m = new Marker(%22test%22, null, latLng);%0A            m.addTo(mapView);%0A            locOverlay.addItem(m);%0A            mapView.invalidate();%0A            //mapView.setCenter(iLatLng);%0A        %7D%0A        //LocationType locationType = new LocationType(mapView, latLng);%0A        //locationType.setLocationType();
 %0A    %7D%0A%0A    
@@ -1694,32 +1694,43 @@
 tLng iLatLng) %7B%0A
+        /*%0A
         LatLng l
@@ -2358,16 +2358,27 @@
 nType();
+%0A        */
 %0A%0A    %7D%0A

make add marker on pick location single tap