2010-06-18 21 views

回答

1

您將需要創建自己的LabeledMarker類,該類繼承自Marker。 This是一個非常好的教程,我用來實現同樣的事情。

0

另一種選擇是什麼Alex suggested可能是使用一組編號的圖標,在以下網站提供的集合,如一個:

那麼你應該能夠執行以下操作(使用第3版API):從上面的例子

<!DOCTYPE html> 
<html> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
    <title>Google Maps Demo</title> 
    <script type="text/javascript" 
      src="http://maps.google.com/maps/api/js?sensor=false"></script> 

    <script type="text/javascript"> 
    function initialize() { 

     var map = new google.maps.Map(document.getElementById("map"), { 
     zoom: 11, 
     center: new google.maps.LatLng(-33.9, 151.2), 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
     }); 

     var locations = [ 
     ['Bondi Beach', -33.890542, 151.274856, 4], 
     ['Coogee Beach', -33.923036, 151.259052, 5], 
     ['Cronulla Beach', -34.028249, 151.157507, 3], 
     ['Manly Beach', -33.80010128657071, 151.28747820854187, 2], 
     ['Maroubra Beach', -33.950198, 151.259302, 1] 
     ]; 

     var image; 

     for (var i = 0; i < locations.length; i++) { 
     image = new google.maps.MarkerImage('marker' + i + '.png', 
              new google.maps.Size(20, 34), 
              new google.maps.Point(0, 0), 
              new google.maps.Point(10, 34)); 

     new google.maps.Marker({ 
      position: new google.maps.LatLng(location[1], location[2]), 
      map: map, 
      icon: image, 
      title: location[0], 
      zIndex: location[3] 
     }); 
     } 
    } 
    </script> 
</head> 
<body style="margin:0px; padding:0px;" onload="initialize();"> 
    <div id="map" style="width:400px; height:500px;"></div> 
</body> 
</html> 

截圖:

Google Numbered Marker Icons http://img716.imageshack.us/img716/3433/nummap.png

請注意,您可以輕鬆地在標記後添加陰影。您可能需要查看Google Maps API Reference: Complex Markers的示例以獲取更多相關信息。

將此示例移植到v2 API應該非常簡單。讓我知道你是否需要這方面的幫助。