[英]How to change the radius of the circle around the marker in Google Map API
I am trying to change the circle radius by changing the value of combo-menu. 我正在尝试通过更改组合菜单的值来更改圆半径。 So I wrote the a function for onchange as below.
所以我写了如下的onchange函数。
function changeRadius(){
var selectedRadius = (document.getElementById("circle_radius").value)*1000;
var circle = new google.maps.Circle({
map: map,
radius: selectedRadius // radius unit is meter.
});
var marker2 = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(40,-90),
draggable: true,
title: 'Drag me!'
});
circle1.bindTo('center', marker2, 'position');
}
But It doesn't work. 但这行不通。 Any idea?
任何想法?
You'll have to do something like this: 您将必须执行以下操作:
google.maps.event.addDomListener(
document.getElementById('circle_radius'), 'change', function() {
circle.setRadius(document.getElementById('circle_radius').value)
});
with this function you'll set up a function as listener for the circle_radius combo value change event. 使用此函数,您可以将一个函数设置为circle_radius组合值更改事件的侦听器。 The function will update the radius of your circle with the value of the combo.
该功能将使用组合的值更新圆的半径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.