Check if google streetview location exists or not to hide a view

萝らか妹 提交于 2019-12-13 15:34:36

问题


I am currently working on an android application which requires me to use street view in my app. I have made a StreetViewActivity to show the street view. But before that activity, I have another activity called Location Activity that has a button that takes the user to the StreetViewActivity. Now my question is how can I check if the latitude and longitude that is provided don't have a streetview then it should hide the button that would prevent the user from going to the StreetViewActivity? I can check if the lat lng exists in my StreetViewActivity but I need to check in the previous activity.

What I have done so far in My StreetViewActivity:

LOCATION = new LatLng(Latitude, Longitude);
    SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
            (SupportStreetViewPanoramaFragment)
                    getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
    streetViewPanoramaFragment.getStreetViewPanoramaAsync(
            new OnStreetViewPanoramaReadyCallback() {
                @Override
                public void onStreetViewPanoramaReady(final StreetViewPanorama panorama) {

                    if (savedInstanceState == null) {

                        panorama.setPosition(LOCATION);
                        panorama.setOnStreetViewPanoramaChangeListener(new StreetViewPanorama.OnStreetViewPanoramaChangeListener() {
                            @Override
                            public void onStreetViewPanoramaChange(StreetViewPanoramaLocation loc) {
                                if (loc != null && loc.links != null) {
                                    //panorama.setPosition(LOCATION);
                                }else{
                                    Toast.makeText(PropertyStreetViewActivity.this, "No Street View Available For This Location", Toast.LENGTH_LONG)
                                            .show();
                                    finish();
                                }
                            }
                        });

                    }
                }
            });

And a Screenshot of my LocationActivity:


回答1:


How to check if latitude and longitude that is provided don't have a streetview was already solved in How to check if Google Street View available and display message?

By default, Street View is enabled on a map and a Street View Pegman control appears integrated within the navigation (zoom and pan) controls. You may hide this control within the map's MapOptions by setting streetViewControl to false.

streetViewControl: false


来源:https://stackoverflow.com/questions/36444274/check-if-google-streetview-location-exists-or-not-to-hide-a-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!