我使用下面的代码通过半径为 60.000m 的单击事件显示圆形。
<html>
<head>
<div id="map"></div>
<style media="screen, projection" type="text/css">
map {
width: 800px;
height: 600px;
}
</style>
</head>
<body>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script><script type="text/javascript">
function initialize()
{
var mapCenter = new google.maps.LatLng(40, -74);
var map = new google.maps.Map(document.getElementById('map'), {
'zoom': 7,
'center': mapCenter,
'mapTypeId': google.maps.MapTypeId.ROADMAP
});
// Add click event listener
google.maps.event.addListener(map, "click", function (e) {
var image = new google.maps.MarkerImage(
'image/data/ConstBuilder/marker.png',
new google.maps.Size(40, 35),
new google.maps.Point(0, 0),
new google.maps.Point(20, 30)
);
var shadow = new google.maps.MarkerImage(
'image/data/ConstBuilder/shadow.png',
new google.maps.Size(62, 35),
new google.maps.Point(0, 0),
new google.maps.Point(0, 35)
);
var marker = new google.maps.Marker({
draggable: true,
raiseOnDrag: false,
icon: image,
shadow: shadow,
map: map,
position: e.latLng
});
var circle = new google.maps.Circle({
map: map,
radius: 60000,
fillColor: '#AA0000'
});
circle.bindTo('center', marker, 'position');
});
};
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html
现在我想再添加一项功能 - 可以更改我的 Click 事件(显示圆圈)的半径值的单选按钮。我知道我需要使用getRadius()
新事件之类的方法,我尝试在下面实现代码但没有成功。
google.maps.event.addDomListener(
document.getElementById('circle_radius'), 'change', function() {
circle.setRadius(document.getElementById('circle_radius').value)
});
谁能帮我找到解决方案?