Hi,
How can calculate distance between node to current login user.
some body help me.

Thanks.
Ravi Kumawat

Comments

hutch’s picture

Assuming that both the node and the user are location enabled, you can use Getdirections to provide you with a map by using a path like this:

getdirections/location_n2u/nnn/uuu

where 'nnn' is the node ID and 'uuu' is the user ID
This will show the total distance if you have enabled that in configuration.
The distance is the distance by road and is calculated by the javascript that fetched the map from Google using the route information provided.
Getdirections does not provide a way of collecting the distance from Google without using a map.

You might be able to write your own javascript that does, see Directions Service for the details on how to use Google API v3

ravi.khetri’s picture

Thanks for this.

But how can get distance between node and user in code(custom modules).
please help me.

hutch’s picture

There are functions in the Getlocations module, see getlocations/modules/getlocations_fields/getlocations_fields.functions.inc, there are functions in there to calculate the distance between two points, eg function getlocations_fields_earth_distance()
You will need to supply the latitude/longitude of each point in decimal degrees.

ravi.khetri’s picture

Thanks .
i am using Drupal 6 and this is not avilable in this.

hutch’s picture

You should be able to use the functions, renamed of course in your custom module.

ravi.khetri’s picture

but i not get getlocations_fields in drupal 6.
please help me with example.

hutch’s picture

Category: task » support

I think you need a php programmer to help you, I have given you all the information you need, the code is there for you to copy and use....