Javascript function to calculate distance between points

S

sarah.kidd

Hello

I was wondering if someone could please help me.


I have created a google map:


http://www.cancerpatientgis.com/markers test/HospPat_markerstest.html


I have some markers which show hospitals and others which show the
patients which attend those hospitals.


I have some html buttons which will call a javascript finction. I am
hoping this javascript finction will calculate the distance between
one hospital and the patients which attend that hospital and display
the shortest distance travelled.


Please could someone give me some help if they know how this can be
done?


Thank you


Sarah
 
T

Thomas 'PointedEars' Lahn

sarah.kidd said:
I have created a google map:
[...]
I have some markers which show hospitals and others which show the
patients which attend those hospitals.

I have some html buttons which will call a javascript finction. I am
hoping this javascript finction will calculate the distance between
one hospital and the patients which attend that hospital and display
the shortest distance travelled.

Please could someone give me some help if they know how this can be
done?

RTFM. The Google Maps API Reference is here:

http://code.google.com/apis/maps/documentation/reference.html

While GLatLng is not a class at all in current client-side ECMAScript
implementations, objects created with this constructor shall have a
distanceFrom() method. If you mean street distance instead, then
GPolyLine::getLength() could be what you are looking for.

The support forums for the Google Maps API are here:

http://groups-beta.google.com/group/Google-Maps-API


HTH

PointedEars
 
B

Bart Van der Donck

sarah.kidd said:
I have created a google map:

http://www.cancerpatientgis.com/markers test/HospPat_markerstest.html

I have some markers which show hospitals and others which show the
patients which attend those hospitals.

I have some html buttons which will call a javascript finction. I am
hoping this javascript finction will calculate the distance between
one hospital and the patients which attend that hospital and display
the shortest distance travelled.

Please could someone give me some help if they know how this can be
done?

I think you'll need to to dig into the Maps API:
http://code.google.com/apis/maps/documentation/reference.html
http://code.google.com/apis/maps/documentation/examples/index.html

To draw lines as the bird flies:
http://code.google.com/apis/maps/documentation/examples/polyline-simple.html

To calculate an itinerary (assumed that it's available in West
Yorkshire county):
http://code.google.com/apis/maps/documentation/examples/directions-advanced.html

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top