我正在尝试在数组中使用航点:
var way = [{ location: { lat: 51.546550, lng: 0.026345 }, stopover: true }, { location: { lat: 51.5493953, lng: 0.0412878 }, stopover: true }];
在地图上加载如下:
<ng-map center="51.546550, 0.026345" zoom="13">
<directions draggable="true"
panel="directions-panel"
waypoints="way"
origin="51.546550, 0.026345"
destination="51.5493953, 0.0412878">
</directions>
</ng-map>
出于某种原因,我得到的错误是:
InvalidValueError:在属性waypoints中:不是数组
如果我直接使用数组,它可以工作:
<ng-map center="51.546550, 0.026345" zoom="13">
<directions draggable="true"
panel="directions-panel"
waypoints="[{ location: { lat: 51.546550, lng: 0.026345 }, stopover: true }, { location: { lat: 51.5493953, lng: 0.0412878 }, stopover: true }]"
origin="51.546550, 0.026345"
destination="51.5493953, 0.0412878">
</directions>
</ng-map>
我错过了什么?
答案 0 :(得分:2)
<强>更新强>
您可以使用waypoints="{{ways}}"
或ng-waypoints = "ways"
。在下面的标记中,我使用了ng-waypoints
。示例here
<ng-map zoom="13" center="51.546550, 0.026345" >
<directions draggable="true"
panel="directions-panel"
ng-waypoints='ways'
origin="51.546550, 0.026345"
destination="51.5493953, 0.0412878">
</directions>
</ng-map>
我使用的js文件是
<script src="ng-map.js"></script>
<script src="http://maps.google.com/maps/api/js"></script>
以下无法使用
您可以尝试$scope.way
而不是var way