Drawing a Line between Two Locations

1,480 views
Skip to first unread message

quincy99

unread,
Feb 17, 2009, 5:26:22 PM2/17/09
to KML Developer Support - Google Earth Plug-in
We're developing a Google Earth application using the Plug In, and
need to draw a line between two addresses.

Does anyone have experience/sample code to do this?

We need to be able to have the code read the original and destination
location each time, and then attach a line between the two point.

Would really appreciate the help.

Thanks much!

Quincy99

Nymor

unread,
Feb 17, 2009, 6:34:31 PM2/17/09
to KML Developer Support - Google Earth Plug-in
Hi,

Some examples you should be able to put together what you want.

Drawing a line between 2 points
http://www.msa.mmu.ac.uk/~fraser/ge/haversine.php
courtesy of our resident guru Fraser. The code there is more
complicated than you need,as it calculates the distance as well, but
the last part of the inline javascript, function createLine, draws a
line between points when you know their lats and longs.

Getting the Lat/Long of a selected placemark
http://earth-api-samples.googlecode.com/svn/trunk/examples/event-placemark.html
If your locations are represented by placemarks this example will help
do what is necessary, event listeners etc, to get the lat/long of the
one that is selected.

Goecode
http://earth-api-samples.googlecode.com/svn/trunk/examples/geocoder.html
Given an address/location get the lat/long via the GMaps geocoder if
the addresses/locations you refer to are just that and not lat/long
points.

Hope that gets you started.

Regards
Nymor


quincy99

unread,
Feb 18, 2009, 9:55:46 AM2/18/09
to KML Developer Support - Google Earth Plug-in
Thank you SO MUCH. We'll try these out and let you know the results.
By-the-way, we did also need to calculate the distance between the two
points, so this should be an ideal solution!! Thanks!!
Quincy99

On Feb 17, 6:34 pm, Nymor wrote:
> Hi,
>
> Some examples you should be able to put together what you want.
>
> Drawing a line between 2 pointshttp://www.msa.mmu.ac.uk/~fraser/ge/haversine.php
> courtesy of our resident guru Fraser. The code there is more
> complicated than you need,as it calculates the distance as well, but
> the last part of the inline javascript, function createLine, draws a
> line between points when you know their lats and longs.
>
> Getting the Lat/Long of a selected placemarkhttp://earth-api-samples.googlecode.com/svn/trunk/examples/event-plac...
> If your locations are represented by placemarks this example will help
> do what is necessary, event listeners etc, to get the lat/long of the
> one that is selected.
>
> Goecodehttp://earth-api-samples.googlecode.com/svn/trunk/examples/geocoder.html
Reply all
Reply to author
Forward
0 new messages