Question

Previously I get an answer to the linking of an element. My next question is: how can I get the "radius" parameter of a binded circle, from the marker?

The code:

var marker = new google.maps.Marker({
  position: new google.maps.LatLng(lat,lng),
});
var circle = new google.maps.Circle({
  map: map, 
  radius: 50,
});
circle.bindTo('map', marker);
circle.bindTo('center', marker, 'position');
Array.push(marker);

I need the cirlce's radius, which binded to the Array[x] marker. Any idea? Thanks in advance!

Was it helpful?

Solution

I don't think there's a way to get a bound object from an object.

What you can do is set the circle as an object on the marker

var marker = new google.maps.Marker({
  position: new google.maps.LatLng(lat,lng),
});
var circle = new google.maps.Circle({
  map: map, 
  radius: 50,
});
marker.circle = circle; // Add the circle object to the map object
circle.bindTo('map', marker);
circle.bindTo('center', marker, 'position');
Array.push(marker);

Now you can get the radius with

Array[x].circle.getRadius();

Working example

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top