var producers = new Array();
var consumers = new Array();
+var postback_url = "${c.postback_url}";
+
/* The URL encoding changes all of our double quotes to ", so we
* have to convert them back before we do anything with the JSON
* data. */
// Close the array, and do something with the result.
json_string += ']';
var F = new Form();
- F.post_data('/directions/json_to_kml', json_string);
+ F.post_data(postback_url, json_string);
}
else {
// Continue the array.
continue;
}
- var producer_latlng = new google.maps.LatLng(producers[i].latitude,
- producers[i].longitude);
-
- var consumer_latlng = new google.maps.LatLng(consumers[i].latitude,
- consumers[i].longitude);
+ /* We'll pass these to the DirectionsRequest object. They aren't
+ * necessarily LatLngs, since if either the latitude or
+ * longitude is missing, we'll fall back to using the name. */
+ var producer_latlng;
+ var consumer_latlng;
+ if (producers[i].latitude && producers[i].longitude) {
+ producer_latlng = new google.maps.LatLng(producers[i].latitude,
+ producers[i].longitude);
+ }
+ else {
+ producer_latlng = producers[i].name;
+ }
+
+ if (consumers[i].latitude && consumers[i].longitude) {
+ consumer_latlng = new google.maps.LatLng(consumers[i].latitude,
+ consumers[i].longitude);
+ }
+ else {
+ consumer_latlng = consumers[i].name;
+ }
+
var directions_request = {
origin: producer_latlng,
destination: consumer_latlng,
- provideTripAlternatives: true,
-
+ provideTripAlternatives: true,
travelMode: google.maps.DirectionsTravelMode.DRIVING
}