I am currently developing an angular application that includes a section for public transportation. I am trying to integrate directions from the Google API, and while the URL seems valid - returning JSON when entered in a browser - I encounter an error when using $.ajax.
URL
http://maps.googleapis.com/maps/api/directions/json?
origin=Assenede,%20Belgi%C3%AB&destination=Industrieweg%20232,Gent-
Mariakerke,belgium&sensor=false&departure_time=1343641500&mode=transit
Angular Controller Function
$scope.getDirections = function(){
var directions_url = "http://maps.googleapis.com/maps/api/directions/json" +
"?origin=" + $scope.details.formatted_address +
"&destination=Industrieweg 232,Gent-Mariakerke,belgium" +
"&sensor=false" +
"&departure_time=1343641500"+
"&mode=transit";
console.log(directions_url);
$.ajax({
type:"GET",
dataType:"json",
contentType:"application/jsonp",
url: directions_url,
success:function(data){
alert(data);
},
error:function(xhr, status, error){
console.log('error:' + status + error);
}
});
}
If anyone has a solution to this issue, your input would be greatly appreciated.
Thank you. HS.