473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Javascript function to calculate distance between points

Hello

I was wondering if someone could please help me.
I have created a google map:
http://www.cancerpatientgis.com/mark...rkerstest.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
Jun 27 '08 #1
2 3233
sarah.kidd wrote:
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/doc...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
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jun 27 '08 #2
sarah.kidd wrote:
I have created a google map:

http://www.cancerpatientgis.com/mark...rkerstest.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/doc...reference.html
http://code.google.com/apis/maps/doc...les/index.html

To draw lines as the bird flies:
http://code.google.com/apis/maps/doc...ne-simple.html

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

Cheers,

--
Bart
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: wired | last post by:
Hi, I've just taught myself C++, so I haven't learnt much about style or the like from any single source, and I'm quite styleless as a result. But at the same time, I really want nice code and I...
24
by: Xah Lee | last post by:
What is Expresiveness in a Computer Language 20050207, Xah Lee. In languages human or computer, there's a notion of expressiveness. English for example, is very expressive in manifestation,...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
4
by: gaga | last post by:
hi guys, a part of my program requires me to calculate an average of items that are sold. the easiest way to do that would be writing a function, but im having trouble making up the parameters. if...
0
by: Killer42 | last post by:
Public Function DistanceBetween(ByVal X1 As Single, ByVal Y1 As Single, ByVal X2 As Single, ByVal Y2 As Single) As Single ' Calculate the distance between two points, given their X/Y coordinates....
3
by: jbanas | last post by:
In MS Access i have a function that is calculating the distance between two locations using the latitude and longitudes for two points assuming the earth is flat and the lat and long are...
10
by: colin | last post by:
Hi, I profile my code and find its spending a lot of time doing implicit conversions from similar structures. the conversions are mainly things like this class Point { implicit conversion...
2
by: Netwatcher | last post by:
can somebody explain me where to put "{ }" and ";" symbols on a script? i did search the web but didn't find any explanation written in a way i can understand. example of a code that i tried and...
10
by: lasmith329 | last post by:
I've never posted a question on any site before, but after racking my head over this hurdle for days, I've caved. I'm working on a program that creates a kml file and exports it to Google Earth. In...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.