I am trying to change the circle radius by changing the value of bo-menu. So I wrote the a function for onchange as below.
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?
I am trying to change the circle radius by changing the value of bo-menu. So I wrote the a function for onchange as below.
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?
Share Improve this question edited Oct 10, 2014 at 20:01 gstackoverflow 37k138 gold badges417 silver badges782 bronze badges asked Sep 26, 2011 at 7:37 karthikeyankkarthikeyank 311 gold badge1 silver badge2 bronze badges 2- 1 google maps api documentation doesn't state any bindTo() function for circle, is it your own function, what does it do? – slawekwin Commented Sep 26, 2011 at 7:57
- This question is a duplicate of stackoverflow./questions/15095118/… , and the answer you want is here : stackoverflow./a/15095490/1290746 – kris Commented Jul 5, 2017 at 5:10
1 Answer
Reset to default 5You'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 bo value change event. The function will update the radius of your circle with the value of the bo.