How to find & highlight nearest POINT PLACEMARK(S) from a clicked point on GE Plugin?

51 views
Skip to first unread message

Shiva

unread,
Jan 7, 2010, 12:43:49 AM1/7/10
to KML Developer Support - Google Earth Plug-in
Hello Everybody,

I am trying to create a GE Plugin application where I have to find &
highlight the nearest point placemark(s). These point placemarks
(lat,long) are added dynamically to the plugin through ajax from a MS
Acess DB. We can get the (lat,long) from the user clicked point, but
how to proceed further, i.e., is there a way to find the nearest point
placemark(s) from a user clicked point on the plugin?

Regards,
Shiva

shsavage

unread,
Jan 7, 2010, 9:02:38 AM1/7/10
to KML Developer Support - Google Earth Plug-in
Hi Shiva,

There isn't an API based command to do this. You have to write it
yourself, but it If your points are not to spread out you can use a
simple Pythagorean distance calculation. The distance you want is the
hypoteneuse of a right triangle; each end of the hypoteneuse is one of
two points to be measured (one of these is the point the user clicks,
and the other is a point from your database; do the calculation in a
loop). So, the square root of (latitude distance squared plus
longitude distance squared) is the distance between the points. Store
the results in an array, sort the array when the loop finishes, and
send the top n results back via your Ajax call, then draw the points
with a different symbol. If the points in your database cover a wide
geographic area, you might consider doing this with a Haversine
distance calculation, but since you're only looking for relative
distances, not absolute, you can probably get by with simply plane
geometry, so the Pythagorean distance will suffice.

-Steve

Shiva

unread,
Jan 8, 2010, 6:10:18 AM1/8/10
to KML Developer Support - Google Earth Plug-in
Hello Steve,

Thank You for replying & reminding me of the Haversine Distance
calculation concept. I found the distance calculation using the
PYTHAGORAS Theorem Concept a little complicated. Since I had used the
Haversine formula for a measurement tool along a line segment drawn on
the google earth plugin, it was easier for me to use the same concept
here. I had to just calculate the distances from the clicked point TO
all the POIs (lat,long) stored in the DB & get the shortest distanced
POI.

Before you reminded me of the same, I was thinking of some impossible
& complex ways to solve it & extensively searched the GE plugin APIs
for the same functionality.

Thanks . . . :-)

Regards,
Shiva



Reply all
Reply to author
Forward
0 new messages