0

以前我得到了一个元素链接的答案。我的下一个问题是:如何从标记中获取绑定圆的“半径”参数?

编码:

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);

我需要圆的半径,它绑定到 Array[x] 标记。任何的想法?提前致谢!

4

1 回答 1

0

我认为没有办法从对象中获取绑定对象。

您可以做的是将圆圈设置为标记上的对象

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);

现在你可以得到半径

Array[x].circle.getRadius();

工作示例

于 2010-11-05T17:23:49.800 回答