3

我正在使用“Gmap3”Jquery 插件并尝试仅初始化街景,没有街景和路线图的组合,也无法在街景和地图之间切换。Gmap3 在其文档 (http://gmap3.net/api/set-street-view.html) 中只有以下 2 个示例:

显示路线图和街景:

var fenway = [42.345573,-71.098326];
$('#test1').gmap3(
{ action:'init',
   zoom: 14,
   mapTypeId: google.maps.MapTypeId.ROADMAP,
   streetViewControl: true,
   center: fenway
}, 
{ action:'setStreetView',
   id: 'test1-streetview',
options:{
   position: fenway,
   pov: {
     heading: 34,
     pitch: 10,
     zoom: 1
     }
   }
});

或在路线图和街景之间切换:

$('#test2').gmap3({
   action:'init',
   zoom: 18,
   mapTypeId: google.maps.MapTypeId.ROADMAP,
   streetViewControl: false,
   center: [40.729884, -73.990988]
});

$('#test2-toggle').click(function(){
$('#test2').gmap3({
   action:'getStreetView',
   callback:function(panorama){
     var visible = panorama.getVisible();
     if (visible) {
       panorama.setVisible(false);
     } else {
       var map = $(this).gmap3('get');
       panorama.setPosition(map.getCenter());
       panorama.setPov({
       heading: 265,
       zoom:1,
       pitch:0}
   );
panorama.setVisible(true);
}
}
});
});

但我很抱歉,我尝试了但找不到有效的解决方案,如何在 div #streetview 中初始化街景。

非常感谢您的帮助,在此先感谢您!

4

2 回答 2

2

老实说,我不知道这个 jquery 插件,但你刚刚使用 Maps API 尝试过吗?

https://developers.google.com/maps/documentation/javascript/streetview

https://google-developers.appspot.com/maps/documentation/javascript/examples/streetview-embed

于 2012-04-25T22:35:29.733 回答
2

我经常使用这个网站,它可以帮助你解决你的问题。http://gmap3.net/api/set-street-view.html街景全景的代码已经过测试和工作:

CSS

.gmap3,.googlemap {
  margin: 20px auto;
  border: 1px dashed #C0C0C0;
  width: 1000px;
  height: 500px;
}

HTML

<div id="test1" class="gmap3"></div><div class="googlemap"></div>
于 2013-07-13T15:51:27.083 回答