[英]How to use GoogleStreetView in Leaflet project?
I have this codes but last step I have a fail. 我有此代码,但最后一步失败了。
map.setStreetView(panorama);----> TypeError: map.setStreetView is not a function map.setStreetView(panorama); ----> TypeError:map.setStreetView不是函数
var fenway = new google.maps.LatLng(latitude,longitude); //fenway = wf {G: 40.989025, K: 29.096618000000035}
Insurance.Map.StreetView(fenway);
StreetView: function (coor) {
var options = {
position: coor,
pov: {
heading: 34,
pitch:10
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById('streetdiv'), options);
map.setStreetView(panorama);
}
setStreetView
is a method of class google.maps.Map
not of Leaflet's L.Map
class. setStreetView
是google.maps.Map
类的方法,而不是Leaflet的L.Map
类的方法。 So that won't work. 这样就行不通了。 You could take a look at this example: http://jsfiddle.net/ALL4k/ which also has the error you describe because it's calling
map.setStreetView
but if you remove of comment out that line, the example keeps working and the error is gone. 您可以看一下以下示例: http : //jsfiddle.net/ALL4k/ ,该示例也存在您描述的错误,因为它正在调用
map.setStreetView
但是如果您删除该行中的注释,该示例将继续工作,并且错误为不见了。
I forgot to set width style. 我忘了设置宽度样式。 I set it and it worked.
我设置好了
<div id='streetdiv' style='width: auto; height: 400px;'></div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.