Cómo verificar si Street View está disponible en la ubicación

I'm using the the Google Maps Android SDK and I'm trying to find out if a StreetView panorama is available is a certain location.

To describe the feature: "If a user click on a map marker and a the location has a panorama then show the panoram, otherwise just zoom the map to the marker location)

I'd rather not create a SupportStreetViewPanoramaFragment if the location doesn't have a panorama. Even if I create it I think the only possible way would be to call setOnStreetViewPanoramaChangeListener and then call setPosition and check the panorama id on the listener... For some reason the listener wasn't called but I didn't try to fix it yet because its feels too cumbersome anyway.

Any elegant solution here ?

I also hope (insist) to avoid calling JavaScript API v3 following this link: https://developers.google.com/maps/documentation/javascript/reference#StreetViewService

var latLng = new google.maps.LatLng(lat, lon);
        streetViewService.getPanoramaByLocation(latLng, STREETVIEW_MAX_DISTANCE, function (streetViewPanoramaData, status) {
            if (status === google.maps.StreetViewStatus.OK) {
                //ok
            } else {
                //no ok
            }
        });

preguntado el 28 de mayo de 14 a las 11:05

I want to check this also. I m trying your above code. I m getting streetViewService cannot be resolved. how to make object of streetViewService. please help -

Make sure you are using the latest Google Play Services -

yes Its the latest one -

2 Respuestas

Simple y fácil

@Override
        public void onStreetViewPanoramaReady(final StreetViewPanorama streetViewPanorama) {
            streetView = streetViewPanorama;
            streetViewPanorama.setOnStreetViewPanoramaChangeListener(new StreetViewPanorama.OnStreetViewPanoramaChangeListener() {
                @Override
                public void onStreetViewPanoramaChange(StreetViewPanoramaLocation streetViewPanoramaLocation) {
                    if (streetViewPanoramaLocation != null && streetViewPanoramaLocation.links != null) {
                        streetView = streetViewPanorama;
                        streetViewPanorama.setPosition(new LatLng(36.0579667, -112.1430996));
                        StreetViewPanoramaCamera camera = new StreetViewPanoramaCamera.Builder()
                                .bearing(180)
                                .build();
                        streetViewPanorama.animateTo(camera, 100);
                    } else {
                        Toast.makeText(StreetView_Panorama.this, "location not available", Toast.LENGTH_SHORT).show();
                    }
                }
            });
        }

respondido 08 nov., 18:06

this is crashing the app - akash dubey

You can use street view metadata. If it returns a pano_id for your marker's location you should be good. Using it needs an API key but it uses no credits. StreetView panorama, on the other hand, got super expensive to use when Google changed their cloud pricing earlier this year. So don't even instantiate one unless you are definitely going to use it.

https://developers.google.com/maps/documentation/streetview/metadata

respondido 23 nov., 18:23

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.