As some of you may have seen I have been working on a google maps mash up
for work. We have it working great however
we have several people from the same company who register. This caused
issues with the map a little so what we determined we would do
is check to see if we have already used that coordinate, if we did we would
add 0.0005 (or something) to the coordinate so that it wouldplot it close
but not on top
of the other markers.
I created this function that takes 2 arrays as arguments
function nextCoord($coords, $usedCoords)
{
list($lat, $lng) = each($coords);
$lat = (float)$lat;
$lng = (float)$lng;
if(in_array($lat.':'.$lng, $usedCoords))
{
$lat += 0.0005;
$lng += 0.0005;
return nextCoord(array($lat, $lng), $usedCoords );
}
$array = array($lat, $lng);
echo '<pre>'; print_r($array); echo '</pre>';
return $array;
}
The issue here is that the print_r that i have there outputs odd results
like the following
Array
(
[0] => 0
[1] => 32.766592
)
I am not sure what is going on there.
Pretty much this function takes the coords in this format lat:lng and checks
them against the $usedCoords array
that is passed into the function. If a match is found it will call the
nextCoord function again until it get's to one that is not
already used.
Can anyone shed any light on the reason why it is returning the odd results
you see above?
Here is the code that consumes the function above
list($attendee['lng'], $attendee['lat'], $attendee['alt']) =
(isset($googleData['kml']['Response'][0]['Placemark'][0]['Point'][0]['coordinates']))
? explode(",",
$googleData['kml']['Response'][0]['Placemark'][0]['Point'][0]['coordinates'])
: array(0,0,0);
$coords = nextCoord(array($attendee['lat'], $attendee['lng']),
$usedCoords);
list($attendee['lat'], $attendee['lng']) = each($coords);
array_push($usedCoords, $attendee['lat'].':'.$attendee['lng']);
--
Joseph Crawford Jr.
Zend Certified Engineer
Codebowl Solutions, Inc.
http://www.codebowl.com/
Blog: http://www.josephcrawford.com/
1-802-671-2021
[EMAIL PROTECTED]
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php