2013-07-04 49 views
0

我的Google地圖工作正常,但鼠標懸停和鼠標未顯示div。任何人都可以看到我的錯誤或我做錯了什麼?我的主機服務器上安裝了jquery。Google地圖工具提示mouseover/mouseout

<html> 
<head> 
<title>Map</title> 
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"> 
<meta charset="utf-8"> 

<script src="jquery/jquery.js"></script> 
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> 

<script type="text/javascript"> 
function initialize() { 
    var LatLng = new google.maps.LatLng(51.620946, -8.890981); 
    var mapOptions = { 
     zoom: 12, 
     center: LatLng, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 

    var map = new google.maps.Map(document.getElementById('map-canvas'), 
     mapOptions); 

    var contentstring = '<div style="height:50px;background-color:red;width:50px;">Hello</div>';   

    var LatLng = new google.maps.LatLng(51.620946, -8.890981); 
    var marker_0 = new google.maps.Marker({ 
     position:LatLng, 
    map:map, 
    descrip:contentstring, 
    link:'https://www.google.ie/' 
    }) 

    google.maps.event.addListener(marker_0,'mouseover',function(){ 
    tooltip.show(this.descrip); 
    }); 

    google.maps.event.addListener(marker_0,'mouseout',function(){ 
     tooltip.hide(); 
    }); 

    google.maps.event.addListener(marker_0,'click',function(){ 
     window.open(this.link);  
    }); 
} 

$(document).ready(function(){ 
    initialize(); 
}) 



</script> 
</head> 
<body> 
    <div id="map-canvas" style="width:600px;height:400px;border:solid 1px red;"></div> 
</body> 
</html> 

在此先感謝您的幫助。

+0

你有什麼錯誤嗎?也許在控制檯中的代碼錯誤?而我無法看到工具提示實際定義在哪裏... –

回答

0

從上面的代碼,它看起來並不像你所定義的變量「提示」

0

不是傳遞descriplink屬性您marker_0,儘量剛好路過title和它的作品。像這樣...

function initialize() { 
    var LatLng = new google.maps.LatLng(51.620946, -8.890981); 
    var mapOptions = { 
     zoom: 12, 
     center: LatLng, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 

    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); 
    var contentstring = '<div style="height:50px;background-color:red;width:50px;">Hello</div>';   

    var marker_0 = new google.maps.Marker({ 
     position:LatLng, 
     map:map, 
     title: contentstring 
     //descrip:contentstring, 
     //link:'https://www.google.ie/' 
    }) 

    /* 

    ** HAVE COMMENTED THIS BIT OUT AS THE MARKER ABOVE WILL WORK AS A TOOL TIP ** 
    google.maps.event.addListener(marker_0,'mouseover',function(){ 
     tooltip.show(this.descrip); 
    }); 

    google.maps.event.addListener(marker_0,'mouseout',function(){ 
     tooltip.hide(); 
    }); 

    google.maps.event.addListener(marker_0,'click',function(){ 
     window.open(this.link);  
    }); */ 
} 

有一個在DOCS一個Simple Marker Exmaple Here

可用於標記的屬性是干邑生產商。

希望這會有所幫助。