开发者

How to use Google Maps to determine the distance between two places?

开发者 https://www.devze.com 2023-03-23 03:04 出处:网络
I wa开发者_开发百科nt to use data from Google Maps in my application. I have two text boxes to add destination A and destination B respectively and I have a panel where I want to show exact mileage o

I wa开发者_开发百科nt to use data from Google Maps in my application.

I have two text boxes to add destination A and destination B respectively and I have a panel where I want to show exact mileage or distance of the destination A from destination B using the same data that appears on the Google Maps web GUI, pictured below.

How can I achieve this?

How to use Google Maps to determine the distance between two places?

populated on my web-page


If you're just directing your users to the Google Maps web site, then note that the URL you've linked to already accepts the source and destination addresses as parameters.

For example, to link to the directions between Delhi and Mumbai:

http://maps.google.com/maps?saddr=delhi&daddr=mumbai


EDIT: Now that you've been clearer about what you want to achieve, it's clear that you'll need to use one of the Google Maps API family. Specifically, I suggest that you look at the Distance Matrix in the Web Services API. It sounds like exactly what you're looking for:

The Google Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations. The information returned is based on the recommended route between start and end points, as calculated by the Google Maps API, and consists of rows containing duration and distance values for each pair.

0

精彩评论

暂无评论...
验证码 换一张
取 消