]> gitweb.michael.orlitzky.com - dead/census-tools.git/blobdiff - jsroute/map.js
Added the jsroute folder with a shell script and sample Javascript file for routing.
[dead/census-tools.git] / jsroute / map.js
diff --git a/jsroute/map.js b/jsroute/map.js
new file mode 100644 (file)
index 0000000..7c28e17
--- /dev/null
@@ -0,0 +1,28 @@
+load('json2.js');
+
+function init_map() {
+  var directions_service = new google.maps.DirectionsService();
+  var directions_request = {
+    origin: start,
+    destination: end,
+    provideRouteAlternatives: true,
+    travelMode: google.maps.DirectionsTravelMode.DRIVING
+  }
+
+  directions_service.route(directions_request, function(result, status) {
+      if (status == google.maps.DirectionsStatus.OK) {
+       output(JSON.stringify(result));
+      }
+      else {
+       output("Error, status: " + status);
+      }
+    });
+    
+  return;
+}
+
+function output(data) {
+  print(data);
+}
+
+window.onload = init_map;