Just curious if anyone knows how to implement the "measure distance" feature found in google maps to the google maps api.
I would like to be able to right-click and have the same functionality that google maps has... any tips?
Thanks!
I was trying to implement this with the "Distance Matrix API" and this node package saved my life: https://www.npmjs.com/package/measuretool-googlemaps-v3
You just have to install it with:
npm i measuretool-googlemaps-v3
Include the MeasureTool.min.js file in your code.
And create a new measure tool object for the google.maps.Map instance:
measureTool = new MeasureTool(map, {
showSegmentLength: true,
tooltip: true,
unit: MeasureTool.UnitTypeId.METRIC // metric, imperial, or nautical
});
Then you will be able to right-click and have the same functionality that google maps have.
Live Demo
I don't know all of their APIs but this one can compute a distance matrix.
https://developers.google.com/maps/documentation/distancematrix/
Otherwise you can see this answer:
Calculate distance between two points in google maps V3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With