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

The following examples show how to use com.google.android.gms.maps.OnStreetViewPanoramaReadyCallback. 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: 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 #3
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 #4
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 #5
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 #6
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();
                            }
                        }
                    });
                }
            }
        });
    }
}