Created
June 19, 2013 21:31
-
-
Save derekeder/5818273 to your computer and use it in GitHub Desktop.
Using Fusion Tables API with Google Distance Matrix API. This code is meant to be added to maps_lib.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
queryPointDistances: function(whereClause) { | |
MapsLib.query("'latitude', 'longitude'", whereClause,"MapsLib.getPointDistances"); | |
}, | |
getPointDistances: function(json) { | |
MapsLib.handleError(json); | |
var data = json["rows"]; | |
var destinations = []; | |
var service = new google.maps.DistanceMatrixService(); | |
for (var row in data) { | |
destinations[row] = new google.maps.LatLng(data[row][0], data[row][1]); // make a lat/long point | |
} | |
service.getDistanceMatrix( | |
{ | |
origins: [MapsLib.currentPinpoint], // where we searched | |
destinations: destinations, | |
travelMode: google.maps.TravelMode.DRIVING, | |
avoidHighways: false, | |
avoidTolls: false | |
}, pointDistanceCallback); | |
}, | |
pointDistanceCallback: function(response, status) { | |
// See Parsing the Results for | |
// the basics of a callback function. | |
// https://developers.google.com/maps/documentation/javascript/distancematrix#distance_matrix_parsing_the_results | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment