Hello,

After about 4 hours of perusing the net and these groups i cannot
figure out why my script used to work, but now does not.

let me preface this by saying that the code i'm about to paste used to
work, but now instead i receive an error telling me the xml file is
missing < (when in actuality it is NULL)

i have even tried directly accessing the url as described in my
function below, and yes, it returns valid xml correctly ...... yet in
my code, it is NULL:



function setup_googlemap_cache($addresses)
{
        for($x = 0;$x < count($addresses);$x++) {
                $fail = TRUE;
                $temp_id = $addresses[$x][0];
                $temp_addy = $addresses[$x][1];
                $temp_type = $addresses[$x][2];

                //look in the db to see if a lat/lng is set.
                //if so, goto next address...if not, set it
                $query = "SELECT lat,lng FROM user WHERE idNum = '" .
prepare_q($temp_id) . "'";
                $result = performQ($query, "users");

                if((float)$result[0][0] === 0.000000 && (float)$result[0][1] ===
0.000000)       {
                        //get the lat/lng
                        $test = "http://maps.google.com/maps/geo?q="; .
urlencode($temp_addy) .
"&output=xml&key=ABQIAAAAXva5RhIe3EUH7hIP98sh4RTu2c_oPNm1xjcn0pbxbwD1PDCAhBTLHYYOSCg65a9QbpZVLTv3_Wv8Ww&oe=utf-8";
                        $response = simplexml_load_file($test);

                        $coords = 
$response->Response->Placemark->Point->coordinates;
                        $status = $response->Response->Status->code;

                        if(strcmp($status, "200") == 0) {
                                //success
                                $coords = explode(",", rtrim($coords));
                                $longitude = $coords[0];
                                $latitude = $coords[1];

                                $fail = FALSE;
                        }
                        elseif(strcmp($status, "620") == 0)     {
                                //too fast
                                $fail = TRUE;
                                usleep(1000);
                                $x--;
                        }
                        else    {
                                //simply failed - bad address maybe?
                                $fail = TRUE;

                                //i'm doing this because if a user makes his 
address his dorm
address, it will fail
                                usleep(1000);
                                $addresses[$x][1] = $_SESSION["city"];
                                $x--;
                        }
                }

                //check for utter failure
                if($fail === FALSE)     {
                        $count_fail = 0;

                        //insert lat/lng into respective table slot
                        $query = "UPDATE user SET lat = " . 
prepare_q($latitude) . ", lng =
" . prepare_q($longitude) . " WHERE idNum = '" . prepare_q($temp_id) .
"'";
                        performQ($query, "users");
                }
        }
}


after a user logs in, an array gets built of all addresses that can be
seen by this person, and after checking the database one at a time for
a set lat/lng, if it is 0.000000 then an attempt to geocode occurs.

if fails (bad address), the geocoder gets the lat/lng for the major
city.


NOTE:  i didn't give you an URL because u would need to create an
account, and this is a new startup for local users, don't want the
idea stolen.

Thanks in advance for reading, i am now 400 hairs closer to baldness.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to