为什么一些街景图片的角度不对? [英] Why are some street-view images from the wrong angle?
问题描述
我使用Google街景图片API来显示地址图片。尽管大多数图片都非常准确,但我注意到一些来自错误角度的图像,如拐角处的房子,图像来自小街,而不是前街。当我查看Google地图时,左侧面板顶部显示的图像是正确的。
示例;
以下图片使用
(如果您不知道地址,则可以将地理位置反向地理位置,以像我这样做)
这个问题的实际例子:使用带有标记的谷歌街景,如何将POV指向标记?
工作代码片段:
var geocoder = new google.maps.Geocoder(); var myStreetView = null; var marker = null; function geocodeAddress(){var address = document.getElementById('address' )。值; geocoder.geocode({'address':address},function(results,status){// alert(results); if(status == google.maps.GeocoderStatus.OK){//alert (results[0].geometry .location); myStreetView = new google.maps.StreetViewPanorama(document.getElementById(map_canvas)); myStreetView.setPosition(results [0] .geometry.location); google.maps.event.addListenerOnce(myStreetView,'status_changed' ,function(){var SVstatus = myStreetView.getStatus()document.getElementById('info')。innerHTML =Street View Status =+ SVstatus; var heading = google.maps.geometry.spherical.computeHeading(myStreetView.getLocation ).latLng,results [0] .geometry.location); myStreetView.setPov({heading:heading,pitch:0}); setTimeout(function(){marker = new google.maps.Marker({position:results [0 ] .geometry.location,map:myStreetView,title:address}); if(mark呃&& marker.setMap)marker.setMap(myStreetView); },500); }); } else {alert(由于以下原因,Geocode不成功:+ status); }}); google.maps.event.addDomListener(document.getElementById('geoBtn'),'click',geocodeAddress);} google.maps.event.addDomListener(window,'load',geocodeAddress);
html,body,#map_canvas {height:100%; width:100%;}
< script src = http://maps.google.com/maps/api/js?libraries=geometry\"> ;</script><input id =addresstype =textvalue =5175 Buena Vista Boulevard,Castle Rock ,CO 80109,USA/>< input id =geoBtntype =buttonvalue =Go/>< div id =info>< / div>< div id = map_canvas>< / div>
I am using the Google Street View Image API to display an image of an address. Although most of the images are amazingly accurate, I've noticed a few that are from the wrong angle like a house on the corner where the image is from the side street, not from the front street. When I check Google Maps the image that shows on the top of the left panel is correct.
Example; Below is an image using the URL parameters from the API instructions; http://maps.googleapis.com/maps/api/streetview?size=300x200&location=39.408751,-104.917738&sensor=false
Below is an image of the same location that displays in the left panel of Google Maps,
Is there a way to get the "better" angle using the API?
If you know the address, and a ROOFTOP geocoder result is available, you can find the closest location on the road, then use that to request the streetview:
(if you don't know the address, you can reverse geocode the location to get it like I did here)
working example from this question: Using google street view with a marker, how do I point the POV at a marker?
working code snippet:
var geocoder = new google.maps.Geocoder();
var myStreetView = null;
var marker = null;
function geocodeAddress() {
var address = document.getElementById('address').value;
geocoder.geocode({
'address': address
}, function(results, status) {
//alert (results);
if (status == google.maps.GeocoderStatus.OK) {
//alert(results[0].geometry.location);
myStreetView = new google.maps.StreetViewPanorama(document.getElementById("map_canvas"));
myStreetView.setPosition(results[0].geometry.location);
google.maps.event.addListenerOnce(myStreetView, 'status_changed', function() {
var SVstatus = myStreetView.getStatus()
document.getElementById('info').innerHTML = "Street View Status="+SVstatus;
var heading = google.maps.geometry.spherical.computeHeading(myStreetView.getLocation().latLng, results[0].geometry.location);
myStreetView.setPov({
heading: heading,
pitch: 0
});
setTimeout(function() {
marker = new google.maps.Marker({
position: results[0].geometry.location,
map: myStreetView,
title: address
});
if (marker && marker.setMap) marker.setMap(myStreetView);
}, 500);
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
google.maps.event.addDomListener(document.getElementById('geoBtn'), 'click', geocodeAddress);
}
google.maps.event.addDomListener(window, 'load', geocodeAddress);
html,
body,
#map_canvas {
height: 100%;
width: 100%;
}
<script src="http://maps.google.com/maps/api/js?libraries=geometry"></script>
<input id="address" type="text" value="5175 Buena Vista Boulevard, Castle Rock, CO 80109, USA" />
<input id="geoBtn" type="button" value="Go" />
<div id="info"></div>
<div id="map_canvas"></div>
这篇关于为什么一些街景图片的角度不对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!