개발
[javascript] 거리 계산 google API
큐베피15
2020. 5. 31. 12:12
728x90
https://developers.google.com/maps/documentation/javascript/distancematrix#transit_options
Distance Matrix Service | Maps JavaScript API | Google Developers
Note: Server-side libraries This page describes the client-side service available with the Maps JavaScript API. If you want to work with Google Maps web services on your server, take a look at the Node.js Client for Google Maps Services. The page at that l
developers.google.com
var origin1 = new google.maps.LatLng(55.930385, -3.118425);
var origin2 = 'Greenwich, England';
var destinationA = 'Stockholm, Sweden';
var destinationB = new google.maps.LatLng(50.087692, 14.421150);
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [origin1, origin2],
destinations: [destinationA, destinationB],
travelMode: 'DRIVING',
transitOptions: TransitOptions,
drivingOptions: DrivingOptions,
unitSystem: UnitSystem,
avoidHighways: Boolean,
avoidTolls: Boolean,
}, callback);
function callback(response, status) {
// See Parsing the Results for
// the basics of a callback function.
}
한국은 DRIVING 지원하지 않고 교통수단인 TRANSIT 을 지원합니다.
var origin1 = new google.maps.LatLng(55.930385, -3.118425);
var destinationA = new google.maps.LatLng(55.930385, -3.118425);
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [origin1],
destinations: [destinationA],
travelMode: 'TRANSIT',
transitOptions: TransitOptions,
drivingOptions: DrivingOptions,
unitSystem: UnitSystem,
avoidHighways: Boolean,
avoidTolls: Boolean,
}, callback);
function callback(response, status) {
// See Parsing the Results for
// the basics of a callback function.
}
728x90
반응형