2012-07-06 93 views
0

完整的新手問題,但我不能工作了如何做到這一點:谷歌地圖跳轉到

http://www.warrensbakery.co.uk/plymouth.htm

我想創建一個鏈接的地圖跳轉到正確的PIN谷歌地圖上顯示地址。

預先感謝您

+0

您應詳細說明你的問題 – RAJ 2012-07-06 19:21:07

+0

遺憾,更增添了幾分信息。希望這是有道理的 – Miles 2012-07-06 19:36:13

回答

1

我做了一個定製的谷歌地圖地圖的幾個地點,每次可以點擊針本身在地圖上和信息窗口會打開。我也想要我相信你在談論的東西 - 點擊地圖之外的鏈接,並在地圖上打開特定引腳的infowindow。實際上它非常簡單 - 只需將click事件設置爲引腳所具有的同一個開放infowindow事件即可。

相關的JavaScript

/* Used variables 
    map = the map itself 
    marker = the current pin 
    infowindow = the infowindow shown on the map 
    - my setup has only one infowindow and clicks just swap its content 
    label = the current infowindow content 
*/ 


// Inside loop setting each pin to the map 

// Click mevent for pins 
google.maps.event.addListener(marker, 'click', function() { 
    infowindow.close; 
    infowindow.setContent(label); 
    infowindow.open(map,marker); 
}); 

// Click event for link outside the map 
$(relevantLink).click(function(){ 
    $("html, body").animate({scrollTop:$("#yourMap").offset().top}, 500); 
    infowindow.close(); 
    infowindow.setContent(label); 
    infowindow.open(map,marker); 
    return false; 
}); 
+0

謝謝道格拉斯,我還是不完全明白,你可能會用一些針腳來演示一個演示嗎?非常感謝 – Miles 2012-07-08 10:39:52

+0

確切的做法取決於你如何使用Google Maps API來設置你的地圖。很有可能,你的某個地方有一些列出你所有的銷釘位置和信息。當你的代碼在數組中循環(這是在你的地圖上設置引腳(每個數組項目有一個引腳)),只需將第二個列出的點擊事件添加到地圖之外的鏈接上,然後打開當前數組項地圖。現在,每個數組項(地圖插針)甚至可以在引腳本身和地圖外的鏈接上進行點擊。 – DACrosby 2012-07-10 23:37:04