com.google.android.gms.maps.StreetViewPanorama Java Examples

The following examples show how to use com.google.android.gms.maps.StreetViewPanorama. 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 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 #3
Source File: StreetViewPanoramaBasicDemoActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.street_view_panorama_basic_demo);

    SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
            (SupportStreetViewPanoramaFragment)
                    getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
    streetViewPanoramaFragment.getStreetViewPanoramaAsync(
            new OnStreetViewPanoramaReadyCallback() {
                @Override
                public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
                    // Only set the panorama to SYDNEY on startup (when no panoramas have been
                    // loaded which is when the savedInstanceState is null).
                    if (savedInstanceState == null) {
                        panorama.setPosition(SYDNEY);
                    }
                }
            });
}
 
Example #4
Source File: StreetViewPanoramaNavigationDemoActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.street_view_panorama_navigation_demo);

    SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
            (SupportStreetViewPanoramaFragment)
                    getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
    streetViewPanoramaFragment.getStreetViewPanoramaAsync(
            new OnStreetViewPanoramaReadyCallback() {
                @Override
                public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
                    mStreetViewPanorama = panorama;
                    // Only set the panorama to SYDNEY on startup (when no panoramas have been
                    // loaded which is when the savedInstanceState is null).
                    if (savedInstanceState == null) {
                        mStreetViewPanorama.setPosition(SYDNEY);
                    }
                }
            });
    mCustomDurationBar = (SeekBar) findViewById(R.id.duration_bar);
}
 
Example #5
Source File: StreetViewFragment.java    From animation-samples with Apache License 2.0 5 votes vote down vote up
private void initMapFragment() {
    mMapFragment = SupportStreetViewPanoramaFragment.newInstance();
    mMapFragment.getStreetViewPanoramaAsync(new OnStreetViewPanoramaReadyCallback() {
        @Override
        public void onStreetViewPanoramaReady(StreetViewPanorama streetViewPanorama) {
            setUpStreetViewPanoramaIfNeeded(mDetail.getPosition());
        }
    });
}
 
Example #6
Source File: StreetViewSettingsActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama streetView)
{
	streetViewPanorama = streetView;
	streetViewPanorama.setPosition(SYDNEY);

	streetViewPanorama.setStreetNamesEnabled(true);
	streetViewPanorama.setPosition(SYDNEY, StreetViewSource.DEFAULT);
	// streetViewPanorama.setPosition(SAN_FRANSISCO,StreetViewSource.OUTDOOR);
	streetViewPanorama.setUserNavigationEnabled(true);
	streetViewPanorama.setZoomGesturesEnabled(true);
	streetViewPanorama.setPanningGesturesEnabled(true);
}
 
Example #7
Source File: StreetViewAndMapActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama streetView)
{
	streetViewPanorama = streetView;

	streetViewPanorama.setOnStreetViewPanoramaChangeListener(this);
	streetViewPanorama.setPosition(SYDNEY);
}
 
Example #8
Source File: StreetViewEventsActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama streetView)
{
	streetViewPanorama = streetView;
	streetViewPanorama.setPosition(SYDNEY);

	streetViewPanorama.setOnStreetViewPanoramaChangeListener(this);
	streetViewPanorama.setOnStreetViewPanoramaCameraChangeListener(this);
	streetViewPanorama.setOnStreetViewPanoramaClickListener(this);
	streetViewPanorama.setOnStreetViewPanoramaLongClickListener(this);
}
 
Example #9
Source File: MapFragment.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
private void initStreetView() {
    getMap().setOnMapLongClickListener( this );

    mStreetViewPanoramaView.getStreetViewPanoramaAsync(new OnStreetViewPanoramaReadyCallback() {
        @Override
        public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
            mPanorama = panorama;
            showStreetView( new LatLng( 40.7506, -73.9936 ) );
        }
    });
}
 
Example #10
Source File: StreetViewNavigationActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 4 votes vote down vote up
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama streetView)
{
	streetViewPanorama = streetView;
	streetViewPanorama.setPosition(SYDNEY);
}
 
Example #11
Source File: StreetViewBasicActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 4 votes vote down vote up
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama streetView)
{
	streetViewPanorama = streetView;
	streetView.setPosition(SYDNEY);
}
 
Example #12
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 #13
Source File: MainActivity.java    From Google-Maps-BottomSheet with The Unlicense 4 votes vote down vote up
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama streetViewPanorama) {
    streetViewPanorama.setPosition(SYDNEY);
    streetViewPanorama.setUserNavigationEnabled(false);
}
 
Example #14
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();
                            }
                        }
                    });
                }
            }
        });
    }
}