如何使用ngmap在多个标记之间绘制多段线?
这是我在使用ng重复的动态标记上的ngmap代码
<div map-lazy-load="http://maps.google.com/maps/api/js" map-lazy-load-params="{{googleMapsUrl}}" class="fullmap">
<map center="{{mapCenter.lat}},{{mapCenter.lng}}" zoom="{{mapCenter.zoom}}" pan-control="true" scrollwheel="false" default-style="false" >
<custom-control id="searchCtrl" position="TOP_CENTER" index="1" on-click="doSearch()">
<button>Search</button>
</custom-control>
<marker ng-repeat="pos in positions" position="{{pos.latitude}}, {{pos.longitude}}"
title="({{pos.deviceTime| date:'medium'}}) GPS: {{pos.latitude}}/{{pos.longitude}}, Speed: {{pos.speed}}, Course: {{pos.course}}"
id="pos{{pos.id}}"
icon="{{'assets/green.png'}}"
visible="true">
</marker>
</map>
</div>
从此链接找到答案
因此,我只需要为shape指令中的路径创建一个纬度和经度的数组对象
HTML
<shape name="polyline" path="{{path}}" geodesic="true" stroke-color="#FF0000" stroke-opacity="1.0" stroke-weight="2"></shape>
控制器
$scope.path = $scope.positions.map(function(position){
return [position.latitude,position.longitude];
});