Search in sources :

Example 1 with GoogleDirection

use of app.akexorcist.gdaplibrary.GoogleDirection in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class DirectionActivity1 method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_direction_1);
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(start, 15));
    gd = new GoogleDirection(this);
    gd.setOnDirectionResponseListener(new OnDirectionResponseListener() {

        public void onResponse(String status, Document doc, GoogleDirection gd) {
            mDoc = doc;
            mMap.addPolyline(gd.getPolyline(doc, 3, Color.RED));
            mMap.addMarker(new MarkerOptions().position(start).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
            mMap.addMarker(new MarkerOptions().position(end).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
            buttonAnimate.setVisibility(View.VISIBLE);
        }
    });
    gd.setOnAnimateListener(new OnAnimateListener() {

        public void onStart() {
            textProgress.setVisibility(View.VISIBLE);
        }

        public void onProgress(int progress, int total) {
            textProgress.setText(progress + " / " + total);
        }

        public void onFinish() {
            buttonAnimate.setVisibility(View.VISIBLE);
            textProgress.setVisibility(View.GONE);
        }
    });
    textProgress = (TextView) findViewById(R.id.textProgress);
    textProgress.setVisibility(View.GONE);
    buttonRequest = (Button) findViewById(R.id.buttonRequest);
    buttonRequest.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            v.setVisibility(View.GONE);
            gd.setLogging(true);
            gd.request(start, end, GoogleDirection.MODE_DRIVING);
        }
    });
    buttonAnimate = (Button) findViewById(R.id.buttonAnimate);
    buttonAnimate.setVisibility(View.GONE);
    buttonAnimate.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            v.setVisibility(View.GONE);
            gd.animateDirection(mMap, gd.getDirection(mDoc), GoogleDirection.SPEED_FAST, true, false, true, false, null, false, true, null);
        }
    });
}
Also used : GoogleDirection(app.akexorcist.gdaplibrary.GoogleDirection) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) OnAnimateListener(app.akexorcist.gdaplibrary.GoogleDirection.OnAnimateListener) OnDirectionResponseListener(app.akexorcist.gdaplibrary.GoogleDirection.OnDirectionResponseListener) OnClickListener(android.view.View.OnClickListener) Document(org.w3c.dom.Document) TextView(android.widget.TextView) View(android.view.View)

Example 2 with GoogleDirection

use of app.akexorcist.gdaplibrary.GoogleDirection in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class DirectionActivity2 method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_direction_2);
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(start, 15));
    gd = new GoogleDirection(this);
    gd.setOnDirectionResponseListener(new OnDirectionResponseListener() {

        public void onResponse(String status, Document doc, GoogleDirection gd) {
            Toast.makeText(getApplicationContext(), status, Toast.LENGTH_SHORT).show();
            gd.animateDirection(mMap, gd.getDirection(doc), GoogleDirection.SPEED_NORMAL, true, true, true, false, null, false, true, new PolylineOptions().width(3));
        }
    });
    gd.request(start, end, GoogleDirection.MODE_DRIVING);
}
Also used : GoogleDirection(app.akexorcist.gdaplibrary.GoogleDirection) OnDirectionResponseListener(app.akexorcist.gdaplibrary.GoogleDirection.OnDirectionResponseListener) Document(org.w3c.dom.Document) PolylineOptions(com.google.android.gms.maps.model.PolylineOptions)

Example 3 with GoogleDirection

use of app.akexorcist.gdaplibrary.GoogleDirection in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class DirectionActivity3 method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_direction_1);
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(start, 15));
    gd = new GoogleDirection(this);
    gd.setOnDirectionResponseListener(new OnDirectionResponseListener() {

        public void onResponse(String status, Document doc, GoogleDirection gd) {
            mDoc = doc;
            mMap.addPolyline(gd.getPolyline(doc, 3, Color.RED));
            buttonAnimate.setVisibility(View.VISIBLE);
        }
    });
    gd.setOnAnimateListener(new OnAnimateListener() {

        public void onStart() {
            textProgress.setVisibility(View.VISIBLE);
        }

        public void onProgress(int progress, int total) {
            textProgress.setText((int) ((float) progress / total * 100) + "% / 100%");
        }

        public void onFinish() {
            buttonAnimate.setVisibility(View.VISIBLE);
            textProgress.setVisibility(View.GONE);
        }
    });
    textProgress = (TextView) findViewById(R.id.textProgress);
    textProgress.setVisibility(View.GONE);
    buttonRequest = (Button) findViewById(R.id.buttonRequest);
    buttonRequest.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            v.setVisibility(View.GONE);
            gd.setLogging(true);
            gd.request(start, end, GoogleDirection.MODE_DRIVING);
        }
    });
    buttonAnimate = (Button) findViewById(R.id.buttonAnimate);
    buttonAnimate.setVisibility(View.GONE);
    buttonAnimate.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            v.setVisibility(View.GONE);
            gd.animateDirection(mMap, gd.getDirection(mDoc), GoogleDirection.SPEED_VERY_SLOW, true, false, true, true, new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.car)), true, false, null);
        }
    });
}
Also used : GoogleDirection(app.akexorcist.gdaplibrary.GoogleDirection) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) OnAnimateListener(app.akexorcist.gdaplibrary.GoogleDirection.OnAnimateListener) OnDirectionResponseListener(app.akexorcist.gdaplibrary.GoogleDirection.OnDirectionResponseListener) OnClickListener(android.view.View.OnClickListener) Document(org.w3c.dom.Document) TextView(android.widget.TextView) View(android.view.View)

Example 4 with GoogleDirection

use of app.akexorcist.gdaplibrary.GoogleDirection in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class SimpleDirection method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_simple_direction);
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(start, 15));
    gd = new GoogleDirection(this);
    gd.setOnDirectionResponseListener(new OnDirectionResponseListener() {

        public void onResponse(String status, Document doc, GoogleDirection gd) {
            mDoc = doc;
            mMap.addPolyline(gd.getPolyline(doc, 3, Color.RED));
            mMap.addMarker(new MarkerOptions().position(start).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
            mMap.addMarker(new MarkerOptions().position(end).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
        }
    });
    buttonRequest = (Button) findViewById(R.id.buttonRequest);
    buttonRequest.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            v.setVisibility(View.GONE);
            gd.setLogging(true);
            gd.request(start, end, GoogleDirection.MODE_DRIVING);
        }
    });
}
Also used : GoogleDirection(app.akexorcist.gdaplibrary.GoogleDirection) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) OnDirectionResponseListener(app.akexorcist.gdaplibrary.GoogleDirection.OnDirectionResponseListener) OnClickListener(android.view.View.OnClickListener) Document(org.w3c.dom.Document) View(android.view.View)

Aggregations

GoogleDirection (app.akexorcist.gdaplibrary.GoogleDirection)4 OnDirectionResponseListener (app.akexorcist.gdaplibrary.GoogleDirection.OnDirectionResponseListener)4 Document (org.w3c.dom.Document)4 View (android.view.View)3 OnClickListener (android.view.View.OnClickListener)3 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)3 TextView (android.widget.TextView)2 OnAnimateListener (app.akexorcist.gdaplibrary.GoogleDirection.OnAnimateListener)2 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)1