Ste*_*eO7 9 google-maps google-street-view
我使用Google街景图像API来显示地址图像.虽然大多数图像都非常准确,但我注意到有一些图像来自错误的角度,就像角落里的房子,图像来自小街,而不是前街.当我查看Google地图时,左侧面板顶部显示的图片是正确的.
例; 下面是使用API指令中的URL参数的图像; http://maps.googleapis.com/maps/api/streetview?size=300x200&location=39.408751,-104.917738&sensor=false

以下是Google地图左侧面板中显示的相同位置的图片,

有没有办法使用API获得"更好"的角度?
如果您知道地址,并且有可用的 ROOFTOP 地理编码器结果,您可以找到道路上最近的位置,然后使用它来请求街景:
(如果您不知道地址,可以像我在这里一样对位置进行反向地理编码以获取它)
这个问题的工作示例:使用带标记的谷歌街景视图,如何将 POV 指向标记?
工作代码片段:
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);Run Code Online (Sandbox Code Playgroud)
html,
body,
#map_canvas {
height: 100%;
width: 100%;
}Run Code Online (Sandbox Code Playgroud)
<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>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2596 次 |
| 最近记录: |