I have the next problem to display a route from basic JSON.
- I do a this call on backend side:
curl to https://maps.googleapis.com/maps/api/directions/json - I send back the response json to frontend
- In frontend I try render the route just for visual, why I don't use the google v3 API to get routeResponse object is because I don't want duplicate the same config as backend use and translate to requestObejct in frontent
- I try to create the routeResponse json based on backend json from googleapi:
data.overviewRouteDirectionSteps.bounds = new google.maps.LatLngBounds( data.overviewRouteDirectionSteps.bounds.southwest,data.overviewRouteDirectionSteps.bounds.northeast); data.overviewRouteDirectionSteps.overview_path=google.maps.geometry.encoding.decodePath(data.overviewRouteDirectionSteps.overview_polyline.points); data.overviewRouteDirectionSteps.overview_polyline = data.overviewRouteDirectionSteps.overview_polyline.points; directionsDisplay.setDirections({ request: { travelModel: 'DRIVING' }, routes: [data.overviewRouteDirectionSteps] });
The problem is I see the start and end markers + legs points but don't see the line:
What should I do to have a correct display routes ? Similar with the flow code:
directionsService.route(request, function(response, status) {
if (status === 'OK') {
console.log(response);
directionsDisplay.setDirections(response);
} else {
console.log('Directions request failed due to ' + status);
}
})
