2010-08-18 125 views
1

我在我的網站上放置谷歌地圖,我想添加點到地圖,但我不知道該怎麼做。我嘗試了一些不同的東西,但他們沒有工作。以下是我迄今爲止:添加點到谷歌地圖API

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> 
    <head> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 
    <title>Google Maps JavaScript API Example: Simple Map</title> 
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=myKeyHere" 
      type="text/javascript"></script> 
    <script type="text/javascript"> 

    function initialize() { 
     if (GBrowserIsCompatible()) { 
     var map = new GMap2(document.getElementById("map_canvas")); 
     map.setCenter(new GLatLng(39.8163, -98.55762), 4); 
     map.setUIToDefault(); 
     } 
    } 

    </script> 
    </head> 
    <body onload="initialize()" onunload="GUnload()"> 
    <div id="map_canvas" style="width: 750px; height: 500px"></div> 
    </body> 
</html> 

回答

1

Google Maps API顯示瞭如何做到這一點的信息。基本上做到:

var point = new GLatLng(latitude,longitude); 
map.addOverlay(new GMarker(point)); 
+0

你會使用一個附加監聽器添加文本標記?我的意思是,如果有人翻過標記,我想要彈出一些文字? – shinjuo 2010-08-18 16:29:43