Yes you are using it wrong. In a webpage you should be using the Javacript Maps API [v3] - that includes classes for running directions queries.
The HTTP web services are for server access, not in a webpage.
Hi,
I am using google distance matrix call to retrieve json result, but it seems it is returning an invalid json result because whenever I am trying to print it in console it is giving me "Uncaught SyntaxError: Unexpected token : " error. Following result is returning from call but whenever I am trying to print it on console it is giving me error as mentioned below.
{"destination_addresses" : [ "Naranpura, Ahmedabad, Gujarat, India" ],Uncaught SyntaxError: Unexpected token :
"origin_addresses" : [ "Navrangpura, Ahmedabad, Gujarat, India" ],"rows" : [{"elements" : [{"distance" : {"text" : "3.5 km","value" : 3548},"duration" : {"text" : "7 mins","value" : 445},"status" : "OK"}]}],"status" : "OK"}
I might be using it in wrong way. Following is my sample code.
var reqUrl = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=Navarangpura ahmedabad&destinations=Naranpura ahmedabad&mode=driving&sensor=false&format=json&anything_else=?";
$.ajax({
type: "GET",
url: reqUrl,
dataType: "jsonp",
success: function (data) {
obj = JSON.parse(data);
console.log(obj);
}
});
Any help would be appreciated.
Thanks.
--
You received this message because you are subscribed to the Google Groups "Google Maps API Web Services" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-api-web-services/-/aTaqHIShpK0J.
To post to this group, send email to google-maps-ap...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api-web-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api-web-services?hl=en.