使用谷歌地图api获取两点之间的路线。响应方向服务已分配给渲染器方向并显示在html:
中$scope.directionsDisplay = new maps.DirectionsRenderer();
var directionsService = new maps.DirectionsService();
$scope.directionsDisplay.setMap( map.control.getGMap());
$scope.directionsDisplay.setPanel(document.getElementById("directions"));
var request = {
origin: ori.coords.latitude + ", " + ori.coords.longitude,
destination: map.center.latitude + ", " + map.center.longitude,
travelMode: maps.TravelMode['DRIVING'],
unitSystem: maps.UnitSystem.METRIC,
optimizeWaypoints: true
};
directionsService.route(request, function (response, status) {
if (status === google.maps.DirectionsStatus.OK) {
$scope.directionsDisplay.setDirections(response);
}
});
此响应显示起点,路线的指示,然后是终点。无法显示初始和结束点?只有迹象。或者它只能通过操纵响应对象来实现?一些类似的例子?
由于
答案 0 :(得分:0)
根据这些说明,我会根据需要删除指令列表中的起点和终点:
delete response.routes[0].legs[0].start_address;
delete response.routes[0].legs[0].end_address;