2014-05-08 63 views
1

有沒有辦法將Google地圖標記上的自定義標記超鏈接到Google地圖上的座標?在這種情況下鏈接到LatLng。另外,有沒有一種方法可以在新選項卡中使用target =「_ blank」或javascript來打開它,但效果相同?超鏈接Google地圖標記爲座標

 function initialize() { 
      var mapOptions = { 
       zoom: 14, 
       center: new google.maps.LatLng(-29.528000, 31.194881) 
      } 
      var map = new google.maps.Map(document.getElementById('ContactMap'), 
              mapOptions); 

      var image = '/Assets/Images/Pages/Marker.png'; 
      var myLatLng = new google.maps.LatLng(-29.528000, 31.194881); 
      var beachMarker = new google.maps.Marker({ 
       position: myLatLng, 
       map: map, 
       icon: image 
      }); 
     } 

     google.maps.event.addDomListener(window, 'load', initialize); 

回答

0

一個真正的超級鏈接是不可能的,但當然,你可以設立一個點擊監聽器來實現類似的行爲:

 google.maps.event.addListener(beachMarker,'click',function(){ 
      window.open('https://maps.google.com/maps?q=' + 
         this.getPosition().toUrlValue() + 
         '&z='+this.getMap().getZoom(),'google'); 
     });