com.google.android.gms.maps.model.StreetViewPanoramaCamera Java Examples

The following examples show how to use com.google.android.gms.maps.model.StreetViewPanoramaCamera. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StreetViewFragment.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
private void setUpStreetViewPanoramaIfNeeded(final LatLng location) {
    mMapFragment.getStreetViewPanoramaAsync(new OnStreetViewPanoramaReadyCallback() {
        @Override
        public void onStreetViewPanoramaReady(StreetViewPanorama streetViewPanorama) {
            if (streetViewPanorama != null) {
                streetViewPanorama.setPosition(location);
                streetViewPanorama.setUserNavigationEnabled(true);
                streetViewPanorama.setPanningGesturesEnabled(true);
                streetViewPanorama.setZoomGesturesEnabled(true);

                StreetViewPanoramaCamera galleryOrientation = StreetViewPanoramaCamera.
                        builder(streetViewPanorama.getPanoramaCamera())
                        .bearing(mDetail.getBearing())
                        .tilt(mDetail.getTilt())
                        .build();
                streetViewPanorama.animateTo(galleryOrientation, TimeUnit.SECONDS.toMillis(1));
            }
        }
    });
}
 
Example #2
Source File: MainActivity.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
private void initStreetView( ) {
	StreetViewPanoramaFragment fragment = ( (StreetViewPanoramaFragment) getFragmentManager().findFragmentById( R.id.street_view_panorama_fragment ) );
	if( mPanorama == null ) {
		if( fragment != null ) {
			mPanorama = fragment.getStreetViewPanorama();
			if( mPanorama != null && mCurrentLocation != null ) {
				StreetViewPanoramaCamera.Builder builder = new StreetViewPanoramaCamera.Builder( mPanorama.getPanoramaCamera() );
				if( mBearing != builder.bearing )
					builder.bearing = mBearing;
				if( mTilt != builder.tilt )
					builder.tilt = mTilt;
				if( mZoom != builder.zoom )
					builder.zoom = mZoom;
				mPanorama.animateTo(builder.build(), 0);
				mPanorama.setPosition( mCurrentLocation, 300 );
				mPanorama.setStreetNamesEnabled( true );
			}
		}
	}
}
 
Example #3
Source File: StreetViewPanoramaNavigationDemoActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
public void onPanDown(View view) {
    if (!checkReady()) {
        return;
    }

    float currentTilt = mStreetViewPanorama.getPanoramaCamera().tilt;
    float newTilt = currentTilt - PAN_BY_DEG;

    newTilt = (newTilt < -90) ? -90 : newTilt;

    mStreetViewPanorama.animateTo(
            new StreetViewPanoramaCamera.Builder()
                    .zoom(mStreetViewPanorama.getPanoramaCamera().zoom)
                    .tilt(newTilt)
                    .bearing(mStreetViewPanorama.getPanoramaCamera().bearing)
                    .build(), getDuration());
}
 
Example #4
Source File: StreetViewPanoramaNavigationDemoActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
public void onPanUp(View view) {
    if (!checkReady()) {
        return;
    }

    float currentTilt = mStreetViewPanorama.getPanoramaCamera().tilt;
    float newTilt = currentTilt + PAN_BY_DEG;

    newTilt = (newTilt > 90) ? 90 : newTilt;

    mStreetViewPanorama.animateTo(
            new StreetViewPanoramaCamera.Builder()
                    .zoom(mStreetViewPanorama.getPanoramaCamera().zoom)
                    .tilt(newTilt)
                    .bearing(mStreetViewPanorama.getPanoramaCamera().bearing)
                    .build(), getDuration());
}
 
Example #5
Source File: NSTStreetView.java    From react-native-streetview with MIT License 6 votes vote down vote up
public void setPov(ReadableMap pov) {

        if (pov == null ) return;
        tilt = (float) pov.getDouble("tilt");
        bearing = (float) pov.getDouble("bearing");
        zoom = pov.getInt("zoom");

        long duration = 1000;
         if (bearing > 0 && this.started) {
             StreetViewPanoramaCamera camera = new StreetViewPanoramaCamera.Builder()
             .zoom(zoom)
             .tilt(tilt)
             .bearing(bearing)
             .build();
             panorama.animateTo(camera,duration);
          }

    }
 
Example #6
Source File: MainActivity.java    From journaldev with MIT License 6 votes vote down vote up
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama streetViewPanorama) {
    mStreetViewPanorama = streetViewPanorama;

    if (secondLocation) {
        streetViewPanorama.setPosition(new LatLng(51.52887, -0.1726073), StreetViewSource.OUTDOOR);
    } else {
        streetViewPanorama.setPosition(new LatLng(51.52887, -0.1726073));
    }
    streetViewPanorama.setStreetNamesEnabled(true);
    streetViewPanorama.setPanningGesturesEnabled(true);
    streetViewPanorama.setZoomGesturesEnabled(true);
    streetViewPanorama.setUserNavigationEnabled(true);
    streetViewPanorama.animateTo(
            new StreetViewPanoramaCamera.Builder().
                    orientation(new StreetViewPanoramaOrientation(20, 20))
                    .zoom(streetViewPanorama.getPanoramaCamera().zoom)
                    .build(), 2000);

    streetViewPanorama.setOnStreetViewPanoramaChangeListener(panoramaChangeListener);


}
 
Example #7
Source File: StreetViewNavigationActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
public void panUp()
{
	float currentTilt = streetViewPanorama.getPanoramaCamera().tilt;
	float newTilt = currentTilt + PAN_BY_DEG;
	newTilt = (newTilt > 90) ? 90 : newTilt;

	streetViewPanorama.animateTo(new StreetViewPanoramaCamera.Builder()
			.zoom(streetViewPanorama.getPanoramaCamera().zoom)
			.tilt(newTilt)
			.bearing(streetViewPanorama.getPanoramaCamera().bearing)
			.build(), 1000);
}
 
Example #8
Source File: MapFragment.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
private void showStreetView( LatLng latLng ) {
    if( mPanorama == null )
        return;

    StreetViewPanoramaCamera.Builder builder = new StreetViewPanoramaCamera.Builder( mPanorama.getPanoramaCamera() );
    builder.tilt( 0.0f );
    builder.zoom( 0.0f );
    builder.bearing( 0.0f );
    mPanorama.animateTo( builder.build(), 0 );

    mPanorama.setPosition( latLng, 300 );
    mPanorama.setStreetNamesEnabled( true );
}
 
Example #9
Source File: StreetViewPanoramaNavigationDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
public void onMovePosition(View view) {
    StreetViewPanoramaLocation location = mStreetViewPanorama.getLocation();
    StreetViewPanoramaCamera camera = mStreetViewPanorama.getPanoramaCamera();
    if (location != null && location.links != null) {
        StreetViewPanoramaLink link = findClosestLinkToBearing(location.links, camera.bearing);
        mStreetViewPanorama.setPosition(link.panoId);
    }
}
 
Example #10
Source File: StreetViewPanoramaNavigationDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
public void onPanRight(View view) {
    if (!checkReady()) {
        return;
    }

    mStreetViewPanorama.animateTo(
            new StreetViewPanoramaCamera.Builder().zoom(
                    mStreetViewPanorama.getPanoramaCamera().zoom)
                    .tilt(mStreetViewPanorama.getPanoramaCamera().tilt)
                    .bearing(mStreetViewPanorama.getPanoramaCamera().bearing + PAN_BY_DEG)
                    .build(), getDuration());

}
 
Example #11
Source File: StreetViewPanoramaNavigationDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
public void onPanLeft(View view) {
    if (!checkReady()) {
        return;
    }

    mStreetViewPanorama.animateTo(
            new StreetViewPanoramaCamera.Builder().zoom(
                    mStreetViewPanorama.getPanoramaCamera().zoom)
                    .tilt(mStreetViewPanorama.getPanoramaCamera().tilt)
                    .bearing(mStreetViewPanorama.getPanoramaCamera().bearing - PAN_BY_DEG)
                    .build(), getDuration());
}
 
Example #12
Source File: StreetViewPanoramaNavigationDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
public void onZoomOut(View view) {
    if (!checkReady()) {
        return;
    }

    mStreetViewPanorama.animateTo(
            new StreetViewPanoramaCamera.Builder().zoom(
                    mStreetViewPanorama.getPanoramaCamera().zoom - ZOOM_BY)
                    .tilt(mStreetViewPanorama.getPanoramaCamera().tilt)
                    .bearing(mStreetViewPanorama.getPanoramaCamera().bearing)
                    .build(), getDuration());
}
 
Example #13
Source File: StreetViewPanoramaNavigationDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
public void onZoomIn(View view) {
    if (!checkReady()) {
        return;
    }

    mStreetViewPanorama.animateTo(
            new StreetViewPanoramaCamera.Builder().zoom(
                    mStreetViewPanorama.getPanoramaCamera().zoom + ZOOM_BY)
                    .tilt(mStreetViewPanorama.getPanoramaCamera().tilt)
                    .bearing(mStreetViewPanorama.getPanoramaCamera().bearing)
                    .build(), getDuration());
}
 
Example #14
Source File: StreetViewPanoramaEventsDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onStreetViewPanoramaClick(StreetViewPanoramaOrientation orientation) {
    Point point = streetViewPanorama.orientationToPoint(orientation);
    if (point != null) {
        panoClickTimes++;
        panoClickTextView.setText(
                "Times clicked=" + panoClickTimes + " : " + point.toString());
        streetViewPanorama.animateTo(
                new StreetViewPanoramaCamera.Builder()
                        .orientation(orientation)
                        .zoom(streetViewPanorama.getPanoramaCamera().zoom)
                        .build(), 1000);
    }
}
 
Example #15
Source File: StreetViewNavigationActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
public void walk()
{
	StreetViewPanoramaLocation location = streetViewPanorama.getLocation();
	StreetViewPanoramaCamera camera = streetViewPanorama.getPanoramaCamera();
	if (location != null && location.links != null)
	{
		StreetViewPanoramaLink link = findClosestLinkToBearing(location.links, camera.bearing);
		streetViewPanorama.setPosition(link.panoId);
	}
}
 
Example #16
Source File: StreetViewNavigationActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
public void zoomOut()
{
	streetViewPanorama.animateTo(new StreetViewPanoramaCamera.Builder()
			.zoom(streetViewPanorama.getPanoramaCamera().zoom - ZOOM_BY)
			.tilt(streetViewPanorama.getPanoramaCamera().tilt)
			.bearing(streetViewPanorama.getPanoramaCamera().bearing)
			.build(), 1000);
}
 
Example #17
Source File: StreetViewNavigationActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
public void zoomIn()
{
	streetViewPanorama.animateTo(new StreetViewPanoramaCamera.Builder()
			.zoom(streetViewPanorama.getPanoramaCamera().zoom + ZOOM_BY)
			.tilt(streetViewPanorama.getPanoramaCamera().tilt)
			.bearing(streetViewPanorama.getPanoramaCamera().bearing)
			.build(), 1000);
}
 
Example #18
Source File: StreetViewNavigationActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
public void panLeft()
{
	streetViewPanorama.animateTo(new StreetViewPanoramaCamera.Builder()
			.zoom(streetViewPanorama.getPanoramaCamera().zoom)
			.tilt(streetViewPanorama.getPanoramaCamera().tilt)
			.bearing(streetViewPanorama.getPanoramaCamera().bearing - PAN_BY_DEG)
			.build(), 1000);
}
 
Example #19
Source File: StreetViewNavigationActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
public void panRight()
{
	streetViewPanorama.animateTo(new StreetViewPanoramaCamera.Builder()
			.zoom(streetViewPanorama.getPanoramaCamera().zoom)
			.tilt(streetViewPanorama.getPanoramaCamera().tilt)
			.bearing(streetViewPanorama.getPanoramaCamera().bearing + PAN_BY_DEG)
			.build(), 1000);
}
 
Example #20
Source File: StreetViewNavigationActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
public void panDown()
{
	float currentTilt = streetViewPanorama.getPanoramaCamera().tilt;
	float newTilt = currentTilt - PAN_BY_DEG;
	newTilt = (newTilt < -90) ? -90 : newTilt;

	streetViewPanorama.animateTo(new StreetViewPanoramaCamera.Builder()
			.zoom(streetViewPanorama.getPanoramaCamera().zoom)
			.tilt(newTilt)
			.bearing(streetViewPanorama.getPanoramaCamera().bearing)
			.build(), 1000);
}
 
Example #21
Source File: StreetViewPanoramaEventsDemoActivity.java    From android-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void onStreetViewPanoramaCameraChange(StreetViewPanoramaCamera camera) {
    panoCameraChangeTextView.setText("Times camera changed=" + ++panoCameraChangeTimes);
}
 
Example #22
Source File: LotInfoFragment.java    From android with MIT License 4 votes vote down vote up
@Override
public void setAttributes(LotAttrs attrs, final StreetView streetView) {
    this.mAttrs = attrs;
    this.mStreetView = streetView;
    if (mAdapter != null) {
        mAdapter.setFooterAttrs(attrs);
    }

    if (vStreetViewPanoramaView != null) {
        vStreetViewPanoramaView.getStreetViewPanoramaAsync(new OnStreetViewPanoramaReadyCallback() {
            @Override
            public void onStreetViewPanoramaReady(final StreetViewPanorama panorama) {
                vStreetViewPanoramaView.setVisibility(View.VISIBLE);
                panorama.setUserNavigationEnabled(false);
                panorama.setPanningGesturesEnabled(false);
                panorama.setZoomGesturesEnabled(false);

                if (!TextUtils.isEmpty(streetView.getId())) {
                    panorama.setPosition(streetView.getId());

                    panorama.setOnStreetViewPanoramaChangeListener(new StreetViewPanorama.OnStreetViewPanoramaChangeListener() {
                        @Override
                        public void onStreetViewPanoramaChange(StreetViewPanoramaLocation streetViewPanoramaLocation) {
                            if (streetViewPanoramaLocation == null) {
                                Log.v(TAG, "Location not found. panoramaId: " + streetView.getId());
                                return;
                            }

                            try {
                                if (streetView.getId().equals(streetViewPanoramaLocation.panoId)) {
                                    panorama.animateTo(new StreetViewPanoramaCamera.Builder()
                                            .zoom(Const.UiConfig.STREET_VIEW_ZOOM)
                                            .bearing(streetView.getHead())
                                            .build(), Const.UiConfig.STREET_VIEW_DELAY);

                                    vStreetViewPanoramaView.postDelayed(new Runnable() {
                                        @Override
                                        public void run() {
                                            ObjectAnimator
                                                    .ofFloat(vStreetViewDelayFix, View.ALPHA, 1, 0)
                                                    .start();
                                        }
                                    }, Const.UiConfig.STREET_VIEW_DELAY);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    });
                }
            }
        });
    }
}
 
Example #23
Source File: NSTStreetView.java    From react-native-streetview with MIT License 4 votes vote down vote up
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {

    this.panorama = panorama;
    this.panorama.setPanningGesturesEnabled(allGesturesEnabled);

    final EventDispatcher eventDispatcher = ((ReactContext) getContext())
            .getNativeModule(UIManagerModule.class).getEventDispatcher();

    this.panorama.setOnStreetViewPanoramaCameraChangeListener(new StreetViewPanorama.OnStreetViewPanoramaCameraChangeListener() {
        @Override
        public void onStreetViewPanoramaCameraChange(StreetViewPanoramaCamera streetViewPanoramaCamera) {
            if (!(streetViewPanoramaCamera.bearing >= 0 ) && coordinate != null) {
                eventDispatcher.dispatchEvent(
                        new NSTStreetViewEvent(getId(), NSTStreetViewEvent.ON_ERROR)
                );
            }
        }
    });

    panorama.setOnStreetViewPanoramaChangeListener(new StreetViewPanorama.OnStreetViewPanoramaChangeListener() {
        @Override
        public void onStreetViewPanoramaChange(StreetViewPanoramaLocation streetViewPanoramaLocation) {
            if (streetViewPanoramaLocation != null) {
                WritableMap map = Arguments.createMap();
                map.putDouble("latitude", streetViewPanoramaLocation.position.latitude);
                map.putDouble("longitude", streetViewPanoramaLocation.position.longitude);
                eventDispatcher.dispatchEvent(
                        new NSTStreetViewEvent(getId(), NSTStreetViewEvent.ON_SUCCESS, map)
                );
            } else {
                eventDispatcher.dispatchEvent(
                        new NSTStreetViewEvent(getId(), NSTStreetViewEvent.ON_ERROR)
                );
            }
        }
    });

    if (coordinate != null) {
        this.panorama.setPosition(coordinate, radius);
    }

   long duration = 1000;
   if (bearing > 0) {
         StreetViewPanoramaCamera camera = new StreetViewPanoramaCamera.Builder()
       .zoom(zoom)
       .tilt(tilt)
       .bearing(bearing)
       .build();
         panorama.animateTo(camera,duration);
    }
    this.started = true;
}
 
Example #24
Source File: StreetViewEventsActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 4 votes vote down vote up
@Override
public void onStreetViewPanoramaCameraChange(StreetViewPanoramaCamera streetViewPanoramaCamera)
{
	Log.d(MainActivity.TAG, "onStreetViewPanoramaCameraChange() called with: streetViewPanoramaCamera = [" + streetViewPanoramaCamera + "]");
}