2013-05-28 64 views
1

我有一張表,其中包含id,名稱,半徑,緯度,&經度列。我想在Google地圖上用不同的圈子標記一些地方。可能嗎?我嘗試使用這種方法:在Google地圖中爲每個標記顯示一個不同的圓圈?

var map = new google.maps.Map(document.getElementById('peta'), options); 
    var locations = [ 
     <?php while($rs = mysql_fetch_array($a_peta, MYSQL_ASSOC)) { ?> 
     ['<?php echo $rs['nama'] ?>', <?php echo $rs['latitude'] ?>, <?php echo $rs['longitude'] ?>], 
     <?php } ?> 
    ]; 

    var infowindow = new google.maps.InfoWindow(); 

    var marker, i; 
    /* kode untuk menampilkan banyak marker */ 
    for (i = 0; i < locations.length; i++) { 
     marker = new google.maps.Marker({ 
      position: new google.maps.LatLng(locations[i][1], locations[i][2]), 
      map: map, 
      icon: 'pics/ico.jpg' 
     }); 

     var circle = new google.maps.Circle({ 
      map: map, 
      radius: '<?php echo $rs['radius'] ?>',  
      fillColor: '#AA0000' 
     }); 
     circle.bindTo('center', marker, 'position'); 

但它不起作用。有什麼方法可以在Google地圖中爲每個標記顯示不同的圈子?

回答

0

半徑一個數字,而不是一個字符串:

radius: <?php echo $rs['radius'] ?>, 

記住半徑以米爲單位,並且必須是足夠高的值要在地圖上是可見的。 P.S.在這種情況下,無論地圖縮放如何,都需要使用屏幕像素計算出的圈數,必須使用其他技術。

+0

你最後一句話正是我想要知道的。我想繪製每個標記不同大小的半徑圓。 什麼樣的技術? –

相關問題