本文介绍了如何知道街景全景是在室内还是室外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天越来越多的企业使用街景来显示室内公寓。



我的计划提供根据选定业务显示街景的能力。但我不想在室内展示。只有户外。由于室内阻挡我移动,只能转360度。



有人知道如何从街景视图API获取某些值,如果我要显示室内还是户外?

非常感谢,

这是我的代码片段根据选定的地址远远打开街道视图:

 函数load_map_and_street_view_from_address(地址){

var地理编码器= 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');
}
});
}


函数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);


$ b函数showPanoData(panoData,status){
if(status!= google.maps.StreetViewStatus.OK){
$(' (''没有StreetView图片可用')。attr('style','text-align:center; font-weight:bold')。show();
return;
}
$('#pano')。show();
var angle = computeAngle(addLatLng,panoData.location.latLng);

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

panorama.setOptions(panoOptions);

}

函数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);
}

函数wrapAngle(angle){
if(angle> = 360){
angle - = 360;
} else if(angle angle + = 360;
}
返回角度;
};

主要想法是获取Panorama位置并验证到360度附近最近位置的距离。

解决方案

我似乎无法为此找到任何正式的API(也许将来他们会执行一个),而我不要以为你可以确定室内瓷砖会有空的描述。



我发现为我工作的是使用这个API:
对此地址运行HTTP GET:与ll = LONG,LAT



这是用于查找目标位置pano_id的内部API。它还为我们提供了一些关于我们可以用它做什么的信息:缩放级别,你在哪条街上等等。



我注意到所有的结果具有室内街景图像的坐标在 data_properties 标记中包含 scene =_ numberlevel_id =_ id全景。因此,对于每个位置,您都可以运行此请求,并在结果XML的data_properties中查找这些值。



一些示例:

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

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

资料来源: p>

更新



看来要让本地商户正确无误pano_id,您需要添加& it = all 给请求
举例:

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

这是正确的pano_id f或这个地方,你可以使用这个API来验证它

  http://cbk0.google.com/cbk?output=tile& ; panoid = 70o9Pukc2KSjO-PfeHussw& zoom = 3& x = 5& y = 1 


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.

解决方案

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 requestexample:

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

这篇关于如何知道街景全景是在室内还是室外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 04:15