Javascript Google Maps Api V3:如何将标记绑定到多边形的顶点?
我试图将标记绑定到多边形的顶点,这样移动标记将更改多边形的形状Javascript Google Maps Api V3:如何将标记绑定到多边形的顶点?,javascript,binding,google-maps-api-3,google-maps-markers,Javascript,Binding,Google Maps Api 3,Google Maps Markers,我试图将标记绑定到多边形的顶点,这样移动标记将更改多边形的形状 var polygonLine = new google.maps.Polyline( { path: [], map: map, strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 2 }); polygonLine.getPath().push(new g
var polygonLine = new google.maps.Polyline(
{
path: [],
map: map,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2
});
polygonLine.getPath().push(new google.maps.LatLng(-31.95202, 115.8548));
polygonLine.getPath().push(new google.maps.LatLng(-31.94980, 115.8586));
polygonLine.getPath().push(new google.maps.LatLng(-31.95246, 115.8625));
polygonLine.getPath().push(new google.maps.LatLng(-31.95508, 115.8558));
var polygon = new google.maps.Polygon({map: map, path: polygonLine.getPath()});
var vertices = polygon.getPath();
for (var i = 0; i < vertices.getLength(); i++)
{
markers[i] = new google.maps.Marker({ position:vertices.getAt(i), map: map, draggable: true });
vertices.getAt(i).bindTo('position', markers[i], 'position'); // Throws an error
}
var polygonLine=新建google.maps.Polyline(
{
路径:[],
地图:地图,
strokeColor:#FF0000“,
笔划不透明度:1.0,
冲程重量:2
});
polygoline.getPath().push(新的google.maps.LatLng(-31.95202115.8548));
polygoline.getPath().push(新的google.maps.LatLng(-31.94980115.8586));
polygoline.getPath().push(新的google.maps.LatLng(-31.95246115.8625));
polygoline.getPath().push(新的google.maps.LatLng(-31.95508115.8558));
var polygon=new google.maps.polygon({map:map,path:polygonLine.getPath()});
var顶点=polygon.getPath();
对于(var i=0;i
现在这不起作用了,因为在最后一行的第二行,vertices.getAt(i)返回一个LatLng,它不支持“position”属性
有人知道我怎么把记号笔绑在一根柱子上吗?谢谢:)我会在这里查看源代码 它似乎基本上添加了一个处理绑定数组的简单类,然后将其与bindTo调用一起使用