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 に答える