我正在使用我的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']; ?>&longs=<? echo
$rows['lng']; ?>&radius=<? echo $rows['distance']; ?>&msisdn=<? echo
$rows['msisdn']; ?>&lbs_log_id=<? echo $rows['lbs_log_id']; ?>"target="_blank"
class="update"><? echo $rows['msisdn']; ?></a>
有没有我可以在我发出的半径点附近添加圆圈?或者最好尝试我不了解的xml功能
答案 0 :(得分:1)
https://developers.google.com/maps/documentation/javascript/reference#CircleOptions
基本上你做的标记与
相同var cirlcle = new google.maps.Circle({
map: map,
center: point,
radius: yourRadius
});
答案 1 :(得分:0)
这样的事情应该起作用
var circle = new google.maps.Circle({
map: map,
radius: 50000, //your radius in meters
fillColor: '#AA0000ff'
center: point
});