feat(distance): add Distance API support #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add full Distance API support to the Node SDK, matching the PHP SDK implementation. This enables distance calculations between coordinates with type-safe enums and a flexible Coordinate class.
Changes
New Features
Coordinate class - Flexible coordinate input handling with validation
"lat,lng"or"lat,lng,id"), arrays ([lat, lng]), or objects ({lat, lng, id})distance() - Single origin to multiple destinations (GET
/distance)distanceMatrix() - Multiple origins × destinations (POST
/distance-matrix)Async Job Methods for large calculations:
createDistanceMatrixJob()- Create background jobdistanceMatrixJobStatus()- Check job statusdistanceMatrixJobs()- List all jobsgetDistanceMatrixJobResults()- Get completed resultsdownloadDistanceMatrixJob()- Download to filedeleteDistanceMatrixJob()- Delete jobEnhanced geocode()/reverse() - Optional distance parameters to calculate distances to destinations
New Types & Enums
DistanceMode: straightline, driving, haversineDistanceUnits: miles, kmDistanceOrderBy: distance, durationDistanceSortOrder: asc, descOther Changes
Test Plan