2013-05-05 87 views
0

(對不起我的英文)我有一個問題closebutton ,,,我正嘗試建立在用戶點擊一個多邊形,並將其移動用戶與谷歌街景另一頁網頁查看全景(這我有)。但我也需要一個代碼,點擊關閉按鈕後,全景移動用戶從「全景頁」回「多邊形」頁。我試圖使用相同的代碼就像我之前使用的移動用戶爲「全景頁面」,但它doesn't工作(它只是關閉的全景,但doesn't回遷「多邊形頁」)。該行:如何設置其他功能全景


    google.maps.event.addListener(panorama, "closeclick", function(event) { window.location = "index.html"; }) 

是將用戶移回「多邊形頁面」(index.html)的代碼。這裏是整個代碼:

function initialize() {

var panoOptions = { 
pano: 'Kuchyn', 
enableCloseButton: true, 
pov: { 
    heading: 0, 
    pitch: 0, 
    zoom: 0 
    }, 
panoProvider: getCustomPanorama, 
visible: true}; 

var panorama = new google.maps.StreetViewPanorama(
document.getElementById('map-canvas'), panoOptions); 

function getCustomPanoramaTileUrl(pano, zoom, tileX, tileY) { 
    return 'images/Untitled.jpg';} 

function getCustomPanorama(pano, zoom, tileX, tiley) { 

if (pano == 'Kuchyn') { 
return { 
    location: 
    {pano: 'Kuchyn', 
    description: 'Kromeriz - Kuchyn'}, 

    links: [], 
    copyright: 'Oznog (c) 2013', 
    Heading: 180, 

    tiles: 
    {tileSize: new google.maps.Size(4096, 2048), 
    worldSize: new google.maps.Size(4096, 2048), 
    centerHeading: 180, 
    verticalFOV: 90, 
    getTileUrl: getCustomPanoramaTileUrl} 
}; 
} 
} 
} 
google.maps.event.addDomListener(window, 'load', initialize); 
google.maps.event.addListener(panorama, "closeclick", function(event) { window.location = "index.html"; }) 

請幫我1月

回答

0

您的全景事件監聽是外initialize功能,將它在全景聲明如下:

var panorama = new google.maps.StreetViewPanorama(
    document.getElementById('map-canvas'), panoOptions); 

// move it here 
google.maps.event.addListener(panorama, "closeclick", function(event) { window.location = "index.html"; }); 

這是因爲你沒有將全景圖聲明爲全局變量,所以它不能正確地附加。另一種選擇是將其聲明爲全局變量var panorama;以上的初始化方法。

乾杯。

+0

你是神! :) :) :) TNX,TNX,TNX :) – oznog 2013-05-05 16:15:24