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!
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.
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: