0

我正在使用我的 SQL 中的数据来绘制地图,我想在标记周围放置一个半径的圆,也保存在我的 SQL 中

目前我正在使用它来获取地图和标记。

<?php
$lats = $_REQUEST['lats'];
$longs = $_REQUEST['longs'];
$radius = $_REQUEST['radius'];
$msisdn = $_REQUEST['msisdn'];
?>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">    </script>
<script type="text/javascript">

 var customIcons = {
  office: {
    icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
    shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
  },
  house: {
    icon: 'http://e-track.co.za/logo.png',
    shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
  }
  };

function load() {
    var map = new google.maps.Map(
        document.getElementById("map"),
        {zoom: 14, mapTypeId: google.maps.MapTypeId.HYBRID}
    );

    var infoWindow = new google.maps.InfoWindow;
    var type = "house";
    var dist = <?php echo json_encode($radius); ?>;
    var lat = <?php echo json_encode($lats); ?>;
    var lng = <?php echo json_encode($longs); ?>;
    var msisdn = <?php echo json_encode($msisdn); ?>;
    var point = new google.maps.LatLng(
          parseFloat(lat),
          parseFloat(lng));
    var html = "<b>Cell: " + msisdn + "</b> <br/>Radius: " + dist + "m";
    var icon = customIcons[type] || {};
    var marker = new google.maps.Marker({
        map: map,
        position: point,
        icon: icon.icon,
        shadow: icon.shadow
    });

    bindInfoWindow(marker, map, infoWindow, html);
    map.setCenter(new google.maps.LatLng(lat, lng));
  }

  function bindInfoWindow(marker, map, infoWindow, html) {
  google.maps.event.addListener(marker, 'click', function() {
    infoWindow.setContent(html);
    infoWindow.open(map, marker);
  });
  }

 function downloadUrl(url, callback) {
  var request = window.ActiveXObject ?
      new ActiveXObject('Microsoft.XMLHTTP') :
      new XMLHttpRequest;

  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      request.onreadystatechange = doNothing;
      callback(request, request.status);
    }
  };

  request.open('GET', url, true);
  request.send(null);
  }

  function doNothing() {}

  </script>

我用以下函数调用 Longs $ Lats

 <a href="../lbs_map/lbs_map.php?lats=<? echo $rows['lat']; ?>&amp;longs=<? echo 
 $rows['lng']; ?>&amp;radius=<? echo $rows['distance']; ?>&amp;msisdn=<? echo  
 $rows['msisdn']; ?>&amp;lbs_log_id=<? echo $rows['lbs_log_id']; ?>"target="_blank" 
 class="update"><? echo $rows['msisdn']; ?></a>

有没有我可以在我发出的半径周围添加圆?还是最好尝试我一无所知的xml函数

4

2 回答 2

1

https://developers.google.com/maps/documentation/javascript/reference#CircleOptions

本质上,您做的事情与标记相同,所以

var cirlcle = new google.maps.Circle({
    map: map,
    center: point,
    radius: yourRadius
});
于 2013-08-26T19:30:04.797 回答
0

像这样的东西应该工作

var circle = new google.maps.Circle({
    map: map,
    radius: 50000, //your radius in meters
    fillColor: '#AA0000ff'
    center: point
});
于 2013-08-26T19:30:22.423 回答