package com.example.admin.myapplication;

import android.graphics.Bitmap;
import android.location.Location;
import android.location.LocationListener;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.LinearLayout;

import com.skt.Tmap.TMapCircle;
import com.skt.Tmap.TMapData;
import com.skt.Tmap.TMapGpsManager;
import com.skt.Tmap.TMapMarkerItem;
import com.skt.Tmap.TMapPOIItem;
import com.skt.Tmap.TMapPoint;
import com.skt.Tmap.TMapView;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity
    implements TMapView.OnLongClickListenerCallback,
        LocationListener,TMapGpsManager.onLocationChangedCallback {

        private TMapView tMapView = null;
        TMapGpsManager gps = null;
        public static String mApiKey = null;
        public static String mBizAppID = null;
        private static final String TAG = "TestTmap";
        Bitmap icon1, icon2;
        TMapCircle tCircle;
        TMapData tMapData;
        TMapPoint point2 = null;

        @Override
        protected void onCreate (Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        LinearLayout liner = (LinearLayout) findViewById(R.id.linear);
        tMapView = new TMapView(this);
        mApiKey = "7ead9ff9-6595-4362-ad43-f0a1b144c4b9";
        tMapView.setSKTMapApiKey(mApiKey);
        liner.addView(tMapView);
        setContentView(liner);

        gps = new TMapGpsManager(MainActivity.this);
        gps.setMinTime(1);
        gps.setMinDistance(1);
        gps.setProvider(gps.NETWORK_PROVIDER);
        gps.OpenGps();

        tMapData = new TMapData();

        tMapView.setZoomLevel(16);
        tMapView.setIconVisibility(true);
        tMapView.setCompassMode(true);
        tMapView.setSightVisible(true);
        tMapView.setMapPosition(TMapView.POSITION_NAVI);
        tMapView.setTrackingMode(true);

    }

    @Override
    public void onLocationChanged(Location location) {

    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {

    }

    @Override
    public void onProviderEnabled(String provider) {

    }

    @Override
    public void onProviderDisabled(String provider) {

    }


    @Override
    public void onLongPressEvent(ArrayList<TMapMarkerItem> arrayList,
                                 ArrayList<TMapPOIItem> arrayList1, TMapPoint tMapPoint) {

    }

    @Override
    public void onLocationChange(Location location) {
            tMapView.setCenterPoint(location.getLongitude(), location.getLatitude());
            tMapView.setLocationPoint(location.getLongitude(), location.getLatitude());
        }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        gps.CloseGps();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }
}


