Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps 从GoogleMaps中的绑定元素获取参数_Google Maps_Bind_Geometry_Markermanager - Fatal编程技术网

Google maps 从GoogleMaps中的绑定元素获取参数

Google maps 从GoogleMaps中的绑定元素获取参数,google-maps,bind,geometry,markermanager,Google Maps,Bind,Geometry,Markermanager,前面我讨论了元素的链接。我的下一个问题是:如何从标记获取绑定圆的“半径”参数 守则: 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

前面我讨论了元素的链接。我的下一个问题是:如何从标记获取绑定圆的“半径”参数

守则:

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

这是个好主意,解决我的问题,谢谢!简单而聪明:)