街景进入infowindow [英] streetview into infowindow
问题描述
我尝试将街景视图显示为infowindow,但我没有收到它,这是我的代码:有人知道它是如何完成的吗? >先进的非常感谢
函数createMarker(myLatlng){
var panoramaOptions = {
position:myLatlng,
pov:{
heading:34,
pitch:10,
zoom:1
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'),panoramaOptions);
map.setStreetView(panorama);
var contentString ='< div id =panostyle =width:200px; height:200px;>< / div>';
var image ='/artworks/icons/myMarker.png';
var marker = new google.maps.Marker({
position:myLatlng,
map:map,
title:myTitle,
icon:image
});
google.maps.event.addListener(marker,'click',function(){
infowindow.setContent(contentString);
infowindow.open(map,marker);
map.setCenter(myLatlng);
});
返回标记;
我用:
var contentString ='< div id =contentstyle =width:250px; height:300px;>< / div>' ;
var infoWindow = new google.maps.InfoWindow({
content:contentString
});
google.maps.event.addListener(marker,click,function (){
infoWindow.open(mapStyled,marker);
var pano = null;
google.maps.event.addListener(infoWindow,'domready',function(){
if(pano!= null){
pano.unbind(position );
pano.setVisible(false);
}
pano = new google.maps.StreetViewPanorama(document.getElementById(content),{
navigationControl:true,
navigationControlOptions:{style:google.maps.NavigationControlStyle.ANDROID},
enableCloseButton:false,
addressControl:false,
linksControl:false
});
pano.bindTo(posit离子,标记);
pano.setVisible(true);
});
google.maps.event.addListener(infoWindow,'closeclick',function(){
pano.unbind(position);
pano.setVisible(false);
pano = null;
});
虽然我无法知道为什么代码不能正常工作。在我的情况下,这是在for循环内解析KML文件(从而为每个点创建一个新的弹出窗口和标记)。
希望这会有所帮助。
经过反思,似乎问题可能是您将pano绑定到div而不是其内容。还请记住解除绑定并重新绑定到不同的标记。
I m trying to show a streetview view into an infowindow, but I m not getting it, this is my code: Does anyone know how it could be done?
Thank you very much in advanced
function createMarker(myLatlng) {
var panoramaOptions = {
position: myLatlng,
pov: {
heading: 34,
pitch: 10,
zoom: 1
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'),panoramaOptions);
map.setStreetView(panorama);
var contentString = '<div id="pano" style="width:200px;height:200px;"></div>';
var image = '/artworks/icons/myMarker.png';
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "myTitle",
icon: image
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map,marker);
map.setCenter(myLatlng);
});
return marker;
}
I use:
var contentString = '<div id="content" style="width:250px;height:300px;"></div>';
var infoWindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(marker, "click", function () {
infoWindow.open(mapStyled, marker);
var pano = null;
google.maps.event.addListener(infoWindow, 'domready', function () {
if (pano != null) {
pano.unbind("position");
pano.setVisible(false);
}
pano = new google.maps.StreetViewPanorama(document.getElementById("content"), {
navigationControl: true,
navigationControlOptions: { style: google.maps.NavigationControlStyle.ANDROID },
enableCloseButton: false,
addressControl: false,
linksControl: false
});
pano.bindTo("position", marker);
pano.setVisible(true);
});
google.maps.event.addListener(infoWindow, 'closeclick', function () {
pano.unbind("position");
pano.setVisible(false);
pano = null;
});
Though I can't off-hand see why your code would not be working. In my case this is within a for loop parsing a KML file (thus creating a new popup and marker for each point).
Hope this helps.
[edit] On reflection it seems that the issue is probably that you're binding 'pano' to the div rather than it's contents. Also remember to unbind and rebind to different markers.
这篇关于街景进入infowindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!