How to know if street view panorama is indoors or outdoors
Asked Answered
S

3

16

Today more and more businesses use street view to show apartments from indoors.

My program supplies ability to show street view according to selected business. But I don't want to show indoors. Only Outdoors. Because Indoors blocks me to move, only to turn 360 degrees.

Does anyone know how to fetch from street view API some value if I'm going to show indoors or outdoors?

Thank you very much,

This is my snippets of code so far that open street view according to selected address:

function load_map_and_street_view_from_address(address) {

var geocoder = new google.maps.Geocoder();
geocoder.geocode( {
    'address': address
}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        var gps = results[0].geometry.location;
        create_map_and_streetview(gps.lat(), gps.lng(), 'map_canvas', 'pano');
    }
 });
}


function create_map_and_streetview(lat, lng, map_id, street_view_id) {
var googlePos = new google.maps.LatLng(lat,lng);

addLatLng = new google.maps.LatLng(lat,lng);
var service = new google.maps.StreetViewService();
service.getPanoramaByLocation(addLatLng, 50, showPanoData);

}

function showPanoData(panoData, status) {
if (status != google.maps.StreetViewStatus.OK) {
    $('#pano').html('No StreetView Picture Available').attr('style', 'text-align:center;font-weight:bold').show();
    return;
}
$('#pano').show();
var angle = computeAngle(addLatLng, panoData.location.latLng);

var panoOptions = {
    position: addLatLng,
    addressControl: false,
    linksControl: false,
    panControl: false,
    zoomControlOptions: {
        style: google.maps.ZoomControlStyle.SMALL
    },
    pov: {
        heading: angle,
        pitch: 10,
        zoom: 1
    },
    enableCloseButton: true,
    visible:true
};

panorama.setOptions(panoOptions);

}

function computeAngle(endLatLng, startLatLng) {
var DEGREE_PER_RADIAN = 57.2957795;
var RADIAN_PER_DEGREE = 0.017453;

var dlat = endLatLng.lat() - startLatLng.lat();
var dlng = endLatLng.lng() - startLatLng.lng();

var yaw = Math.atan2(dlng * Math.cos(endLatLng.lat() * RADIAN_PER_DEGREE), dlat)
* DEGREE_PER_RADIAN;
return wrapAngle(yaw);
}

function wrapAngle(angle) {
if (angle >= 360) {
    angle -= 360;
} else if (angle < 0) {
    angle += 360;
}
return angle;
};

The main Idea was to get Panorama location and verify distance to closest places around 360 degrees.

Situation answered 10/2, 2013 at 10:6 Comment(6)
Looks like similar requests have been submitted as bugs/enhancements: code.google.com/p/gmaps-api-issues/issues/…Auditory
I'm not posting this as an answer as it may change any day, but for now I found that each property of panorama.links has a description property (containing the street name) if the panorama location is outdoors and is empty if its indoors, so based on this you can test if (panorama.links.length === 0 || panorama.links[0].description == ""), it should return true if indoors. I should add that I didn't test it extensively so i'm not sure it will hold. And I believe that this will change soonDialect
Thanks, let me test your waySituation
Your flow works good, the problem is that I need open street view for each location otherwise panorama.links is undefined. Im looking for the way to do not open street view, only to use its API. Thanks anywaySituation
You are right. You can see by applying the pano_id in the result, to this API cbk0.google.com/… , that the closest panorama the API finds for this location is on the outside of the building. I will continue to investigate :)Overpraise
Found a solution and updated my answer.Overpraise
O
11

I can't seem to find any formal API for this (maybe in the future they will implement one), and I don't think that you can be sure that indoor tiles will be with empty description.

What I found to be working for me is using this API: Run an HTTP GET to this address: "http://cbk0.google.com/cbk?output=xml&ll=52.358445,4.88103" with the ll=LONG,LAT

This is an internal API used to find a target location pano_id. It also gives us some information on what we can do with it: zoom levels, what streets you're on, etc.

I've noticed that all the results for coordinates that have indoor street view images, have scene="_number" level_id="_id" in the data_properties tag of the panorama. And so, for each location you can run this request and look for these values in the data_properties of the result XML

some examples:

indoors:
http://cbk0.google.com/cbk?output=xml&ll=52.358445,4.88103
http://maps.google.com/cbk?output=xml&ll=32.051626,34.7613

outdoors:
http://cbk0.google.com/cbk?output=xml&ll=52.358766,4.880494
http://maps.google.com/cbk?output=xml&ll=32.07782,34.785789

Source: Hacking google street view

Update

It seems that to get local businesses right pano_id you need to add &it=all to the request example:

http://cbk0.google.com/cbk?output=xml&hl=x-local&ll=34.058593,-118.240673&it=all

this the the right pano_id for this place, you can verify it using this API

http://cbk0.google.com/cbk?output=tile&panoid=70o9Pukc2KSjO-PfeHussw&zoom=3&x=5&y=1
Overpraise answered 22/2, 2013 at 8:16 Comment(1)
If during next 2 days - no other choices, 50 points yours, thanksSituation
S
4

Here's a feature request I filed with Google:
"Option to disable indoor street views"
https://code.google.com/p/gmaps-api-issues/issues/detail?id=4831

Feel free to star the ticket there to help it get some attention

(Is this OK etiquette-wise? ...not a real answer (yet), but seems worthy of sharing here so interested parties can star/track the ticket)

Selfheal answered 11/4, 2013 at 22:30 Comment(1)
Yes, this is good information. Annoying missing feature, ticket starred. Hope it gets some attention.Footwall
D
4

The ability to filter out indoor street view panoramas was implemented in Google Maps JavaScript API some time ago.

You can use StreetViewService to search only outdoor panoramas. In the request you should specify the source as outdoor

https://developers.google.com/maps/documentation/javascript/reference/3/#StreetViewSource

Have a look at the following sample code that demonstrates how to get only outdoor panoramas

var panorama;
function initialize() {
    var svService = new google.maps.StreetViewService();
    var panoRequest = {
        location: new google.maps.LatLng(37.800953,-122.436738),
        preference: google.maps.StreetViewPreference.NEAREST,
        radius: 50,
        source: google.maps.StreetViewSource.OUTDOOR
    };

    svService.getPanorama(panoRequest, function(panoData, status){
        if (status === google.maps.StreetViewStatus.OK) {
            panorama = new google.maps.StreetViewPanorama(
                document.getElementById('street-view'),
                {
                    pano: panoData.location.pano,
                    pov: {
                        heading: 10,
                        pitch: 10
                    }
                });
        } else {
            //Handle other statuses here
        }
    });
}
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
#street-view {
  height: 100%;
}
<div id="street-view"></div>
<script async defer
         src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDztlrk_3CnzGHo7CFvLFqE_2bUKEq1JEU&callback=initialize">
    </script>

I hope this helps!

Dwinnell answered 19/3, 2018 at 13:34 Comment(1)
This should now be the accepted answer I guess!Ability

© 2022 - 2024 — McMap. All rights reserved.