Search in sources :

Example 26 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions 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 27 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions 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 28 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class PlaceActivity2 method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_place_2);
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 15));
    gp = new GooglePlaceSearch(ApiKey);
    gp.setOnPlaceResponseListener(new OnPlaceResponseListener() {

        public void onResponse(String status, ArrayList<ContentValues> arr_data, Document doc) {
            Toast.makeText(getApplicationContext(), status, Toast.LENGTH_SHORT).show();
            if (status.equals(GooglePlaceSearch.STATUS_OK)) {
                for (int i = 0; i < arr_data.size(); i++) {
                    String title = arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_NAME);
                    double lat = arr_data.get(i).getAsDouble(GooglePlaceSearch.PLACE_LATITUDE);
                    double lng = arr_data.get(i).getAsDouble(GooglePlaceSearch.PLACE_LONGITUDE);
                    LatLng pos = new LatLng(lat, lng);
                    mMap.addMarker(new MarkerOptions().position(pos).title(title));
                }
            }
        }
    });
    gp.getNearby(latitude, longitude, radius, type, language);
//gp.getRadarSearch(latitude, longitude, radius, type, language, false);
}
Also used : ContentValues(android.content.ContentValues) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) GooglePlaceSearch(app.akexorcist.gdaplibrary.GooglePlaceSearch) OnPlaceResponseListener(app.akexorcist.gdaplibrary.GooglePlaceSearch.OnPlaceResponseListener) LatLng(com.google.android.gms.maps.model.LatLng) Document(org.w3c.dom.Document)

Example 29 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions 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)

Example 30 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class GoogleDirection method animateDirection.

public void animateDirection(GoogleMap gm, ArrayList<LatLng> direction, int speed, boolean cameraLock, boolean isCameraTilt, boolean isCameraZoom, boolean drawMarker, MarkerOptions mo, boolean flatMarker, boolean drawLine, PolylineOptions po) {
    if (direction.size() > 1) {
        isAnimated = true;
        animatePositionList = direction;
        animateSpeed = speed;
        this.drawMarker = drawMarker;
        this.drawLine = drawLine;
        this.flatMarker = flatMarker;
        this.isCameraTilt = isCameraTilt;
        this.isCameraZoom = isCameraZoom;
        step = 0;
        this.cameraLock = cameraLock;
        this.gm = gm;
        setCameraUpdateSpeed(speed);
        beginPosition = animatePositionList.get(step);
        endPosition = animatePositionList.get(step + 1);
        animateMarkerPosition = beginPosition;
        if (mAnimateListener != null)
            mAnimateListener.onProgress(step, animatePositionList.size());
        if (cameraLock) {
            float bearing = getBearing(beginPosition, endPosition);
            CameraPosition.Builder cameraBuilder = new CameraPosition.Builder().target(animateMarkerPosition).bearing(bearing);
            if (isCameraTilt)
                cameraBuilder.tilt(90);
            else
                cameraBuilder.tilt(gm.getCameraPosition().tilt);
            if (isCameraZoom)
                cameraBuilder.zoom(zoom);
            else
                cameraBuilder.zoom(gm.getCameraPosition().zoom);
            CameraPosition cameraPosition = cameraBuilder.build();
            gm.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
        }
        if (drawMarker) {
            if (mo != null)
                animateMarker = gm.addMarker(mo.position(beginPosition));
            else
                animateMarker = gm.addMarker(new MarkerOptions().position(beginPosition));
            if (flatMarker) {
                animateMarker.setFlat(true);
                float rotation = getBearing(animateMarkerPosition, endPosition) + 180;
                animateMarker.setRotation(rotation);
            }
        }
        if (drawLine) {
            if (po != null)
                animateLine = gm.addPolyline(po.add(beginPosition).add(beginPosition).add(endPosition).width(dpToPx((int) po.getWidth())));
            else
                animateLine = gm.addPolyline(new PolylineOptions().width(dpToPx(5)));
        }
        new Handler().postDelayed(r, speed);
        if (mAnimateListener != null)
            mAnimateListener.onStart();
    }
}
Also used : CameraPosition(com.google.android.gms.maps.model.CameraPosition) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Handler(android.os.Handler) PolylineOptions(com.google.android.gms.maps.model.PolylineOptions)

Aggregations

MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)38 LatLng (com.google.android.gms.maps.model.LatLng)23 BitmapDescriptor (com.google.android.gms.maps.model.BitmapDescriptor)7 Marker (com.google.android.gms.maps.model.Marker)6 GoogleMap (com.google.android.gms.maps.GoogleMap)5 Bitmap (android.graphics.Bitmap)4 View (android.view.View)4 Document (org.w3c.dom.Document)4 OnClickListener (android.view.View.OnClickListener)3 GoogleDirection (app.akexorcist.gdaplibrary.GoogleDirection)3 OnDirectionResponseListener (app.akexorcist.gdaplibrary.GoogleDirection.OnDirectionResponseListener)3 OnMapReadyCallback (com.google.android.gms.maps.OnMapReadyCallback)3 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)3 RemoteImageLoader (com.omkarmoghe.pokemap.helpers.RemoteImageLoader)3 TextView (android.widget.TextView)2 OnAnimateListener (app.akexorcist.gdaplibrary.GoogleDirection.OnAnimateListener)2 CameraPosition (com.google.android.gms.maps.model.CameraPosition)2 CircleOptions (com.google.android.gms.maps.model.CircleOptions)2 PokemonIdOuterClass (POGOProtos.Enums.PokemonIdOuterClass)1 FortDataOuterClass (POGOProtos.Map.Fort.FortDataOuterClass)1