gpt4 book ai didi

javascript - Google 从 getPaths 坐标映射 setPaths

转载 作者:行者123 更新时间:2023-11-30 18:19:33 24 4
gpt4 key购买 nike

我正在尝试获取一个多边形的路径,然后将它们设置为另一个类似的多边形。

newpoly = new google.maps.Polygon({
paths:poly.getPaths()
});

这不是应该工作吗?它在控制台中给我这个错误。

构造函数参数 0 的无效值:[object Object]

最佳答案

在实例化多边形对象之前尝试添加以下内容

var triangleCoords = [
new google.maps.LatLng(25.774252, -80.190262),
new google.maps.LatLng(18.466465, -66.118292),
new google.maps.LatLng(32.321384, -64.75737),
new google.maps.LatLng(25.774252, -80.190262)
];

现在使用您的代码并替换 poly.getPaths() - 假设您的其余代码有效。

newpoly = new google.maps.Polygon({
paths:triangleCoords //there are probably more method to add here
});

如果它有效,那么您就知道 poly.getPaths() 有问题。以此为引用 https://developers.google.com/maps/documentation/javascript/overlays#PolygonOptions .

请记住,我们只能使用提供的代码来制定解决方案。

关于javascript - Google 从 getPaths 坐标映射 setPaths,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12445039/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com