Google 地图 v3 中的自动街景转换

发布于 2024-09-13 04:35:56 字数 303 浏览 4 评论 0原文

如果您访问 http://maps.google.com 并放大直至 Google 耗尽地图查看器自动转换到街景模式(至少在您放大的位置可以使用街景时)。

我正在研究 Google Maps v3 API。有没有办法在这里复制地图到街景的效果?我可以通过将 streetViewControl: true 放入 mapOptions 中来启用街景,但用户仍然需要手动将火柴人拖到地图上才能启动街景。

If you go to http://maps.google.com and zoom in until Google runs out of map the viewer automatically transitions to Streetview-mode (at least if Streetview is available at the location you zoomed in on).

I'm mucking around with the Google Maps v3 API. Is there a way to replicate the map-to-streetview effect here? I can enable Streetview just fine by putting streetViewControl: true in the mapOptions, but the user still has to manually drag the stickman onto the map to get Streetview going.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

混浊又暗下来 2024-09-20 04:35:57

这将在地图中心打开全景图:

var G = google.maps;
var svpContainer = document.getElementById('svp'); // Make sure this div exists
var svp = new G.StreetViewPanorama(svpContainer);
G.event.addListener(map, 'zoom_changed', function(){
    var z = map.getZoom();
    var center = map.getCenter();
    if (z > 15) {
        svp.setPosition(center);
        svp.setVisible(true);
    }

});

在德克萨斯州达拉斯进行测试。确保您有一个 id 为“svp”的 div

This will open a panorama at the map center:

var G = google.maps;
var svpContainer = document.getElementById('svp'); // Make sure this div exists
var svp = new G.StreetViewPanorama(svpContainer);
G.event.addListener(map, 'zoom_changed', function(){
    var z = map.getZoom();
    var center = map.getCenter();
    if (z > 15) {
        svp.setPosition(center);
        svp.setVisible(true);
    }

});

Tested over Dallas, TX. Make sure you have a div with id 'svp'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文