Search in sources :

Example 6 with CameraPosition

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

Example 7 with CameraPosition

use of com.google.android.gms.maps.model.CameraPosition in project Remindy by abicelis.

the class LocationBasedReminderDetailFragment method setUpMap.

@SuppressWarnings({ "MissingPermission" })
private void setUpMap() {
    mMap.setMyLocationEnabled(true);
    //mMap.setPadding(0, ConversionUtil.dpToPx(68, getResources()), 0, 0);
    mMap.getUiSettings().setMyLocationButtonEnabled(true);
    //Add circle and marker
    int strokeColor = ContextCompat.getColor(getActivity(), R.color.map_circle_stroke);
    int shadeColor = ContextCompat.getColor(getActivity(), R.color.map_circle_shade);
    LatLng latLng = ConversionUtil.placeToLatLng(mReminder.getPlace());
    mMap.addCircle(new CircleOptions().center(latLng).radius(mReminder.getPlace().getRadius()).fillColor(shadeColor).strokeColor(strokeColor).strokeWidth(2));
    mMap.addMarker(new MarkerOptions().position(latLng));
    //Move camera
    //mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latlng, 15), 1000, null);  //Zoom level 15 = Streets, 1000ms animation
    CameraPosition cameraPos = new CameraPosition.Builder().tilt(60).target(latLng).zoom(15).build();
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPos), 1000, null);
}
Also used : CameraPosition(com.google.android.gms.maps.model.CameraPosition) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) CircleOptions(com.google.android.gms.maps.model.CircleOptions) LatLng(com.google.android.gms.maps.model.LatLng)

Example 8 with CameraPosition

use of com.google.android.gms.maps.model.CameraPosition in project Remindy by abicelis.

the class PlaceActivity method moveCameraToLocation.

private void moveCameraToLocation(Location location) {
    if (location != null) {
        //Point map camera to location
        LatLng latlng = new LatLng(location.getLatitude(), location.getLongitude());
        //mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latlng, 15), 1000, null);  //Zoom level 15 = Streets, 1000ms animation
        CameraPosition cameraPos = new CameraPosition.Builder().tilt(60).target(latlng).zoom(15).build();
        mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPos), 1000, null);
    }
}
Also used : CameraPosition(com.google.android.gms.maps.model.CameraPosition) LatLng(com.google.android.gms.maps.model.LatLng)

Aggregations

CameraPosition (com.google.android.gms.maps.model.CameraPosition)8 LatLng (com.google.android.gms.maps.model.LatLng)2 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)2 Handler (android.os.Handler)1 CircleOptions (com.google.android.gms.maps.model.CircleOptions)1 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1