我正在尝试访问shape
并将其解析/转换为Polygon对象,以便检索getPath().getArrays()
有没有什么方法可以让我从html中检索<shape>
并在我的控制器中使用它?
$scope.insertAt = function (event) {
const shape = document.getElementById('polygon');
const polygon = new google.maps.Polygon(shape);
console.log("Polygon ", polygon);
// error here --> polygon.getPath().getArray();
};
<shape name="polygon" id="polygon" stroke-color="#FF0000"
stroke-opacity="1.0"
stroke-weight="2"
draggable="true"
geodesic="false"
editable="true"
insert-at="{{insertAt()}}"
paths="{{mappedGeoCoordinates}}" >
</shape>
谢谢
1条答案
按热度按时间h6my8fg21#
您尝试将形状直接转换为多边形,但需要先从形状获取路径,然后传递这些路径。
我不确定你的$scope.insertAt是什么。假设这是你自己的属性?