作为标题,我在数据库中保存了很多坐标,当我点击按钮时我会得到它。单击按钮时,我可以显示所有标记,但我无法使用这些标记绘制折线。
这是我的代码:
<div ng-app="AAA" ng-controller="Controller">
<button ng-click="SendGetPath()">Get</button>
<div class="maps">
<!-- Add directive code (gmap directive) for show map and markers-->
<ui-gmap-google-map center="map.center" zoom="map.zoom">
<ui-gmap-marker ng-repeat="marker in markers" coords="marker.coords" options="marker.options" events="marker.events" idkey="marker.id">
<ui-gmap-window options="windowOptions" show="windowOptions.show">
<div style="max-width:200px">
<div class="header"><strong>{{marker.time}}</strong></div>
</div>
</ui-gmap-window>
</ui-gmap-marker>
<ui-gmap-polyline path="map.polyline.path" stroke="map.polyline.stroke" visible='map.polyline.visible' geodesic='map.polyline.geodesic' fit="false"></ui-gmap-polyline>
</ui-gmap-google-map>
</ui-gmap-google-map>
</div>
在javascript中,
var app = angular.module('AAA', ['uiGmapgoogle-maps']);
app.controller('Controller', function ($scope, $http) {
//this is for default map focus when load first time
$scope.map = { center: { latitude: 22.25, longitude: 114.1667 }, zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP }
$scope.carlist = [];
$scope.locations = [];
var id = 1;
//Send command to device
$scope.SendGetPath = function () {
$http.get('GetPath', {
params: {
regno: document.getElementById('car').value,
date: document.getElementById('date').value
}
}).then(function (data) {
//alert("Sent");
$scope.locations = data.data;
$scope.markers = [];
angular.forEach($scope.locations, function (value, key) {
$scope.markers.push({
id: id,
coords: { latitude: value.Latitude, longitude: value.Longitude },
//title: value.RegNo,
//battery: value.Battery
//address: data.data.Address,
//image : data.data.ImagePath
time: value.Time
});
id=id+1;
});
$scope.map = { center: { latitude: 22.25, longitude: 114.1667 }, zoom: 12 }
}, function () {
//alert('Load Error');
});
}
});
如何将箭头添加到地图的路径?