从Google Maps中的媒体元素获取参数
-
29-09-2019 - |
题
以前我 得到答案 到元素的链接。我的下一个问题是:如何从标记中获取绑定圆的“半径”参数?
编码:
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);
我需要cirlce的半径,它伴随着数组[x]标记。任何的想法?提前致谢!
解决方案
我认为没有办法从对象中获取绑定对象。
您可以做的是将圆设置为标记上的对象
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();
不隶属于 StackOverflow