You are right, it's a PHP issue, not a javascript one.  I couldn't see
your site, but your problem is likely that you are trying to compare a
floating value to a string. Here's what I would do with the sample
code:

while ($row = @mysql_fetch_assoc($result)) {

  // check if the address is already geocoded. If so, do nothing.
  // (note: if the address geocoding failed before, it will continue
to be retried each time.
  //          A better solution would likely be to add a new field to
the table, which flags
  //          if the address has been geocoded or not. - OR - geocode
when you first add
  //          he record to the table, and never run this batch
geocoding)

  if ($row["lat"] == 0 && $row["lng"] == 0) {
      // address hasn't been geocoded, since lat and lng are both 0.
      $geocode_pending = true;
      while ($geocode_pending) {
         ...blah blah blah. geocode it.
      }
  }

one other thought:  I wouldn't use a floating type value for lat and
lng, even though Google did in the example.  I prefer a fixed decimal
place (9 digits, 6 decimal places).  I think it's more efficient, and
not subject to rounding errors.

Good luck!

-Mike Ethetton
http://mastertoolworks.com
http://mappingcenter.org


On Jul 28, 11:48 pm, Classick <dave.class...@gmail.com> wrote:
> Hello googlers,
>
> I am fairly new to the API, but have some previous experience with
> coding.
>
> I have a quick question. I have a markers DB table with only about 200
> or so records in it., and i am trying to batch geocode every time i
> add new records.
>
> I used the sample code from the API tutorials, and everything works
> fine... but what id like to do, and like to suggest for the tutorial,
> is a small augmentation of the code.
>
> this code from the tutorial (http://code.google.com/apis/maps/articles/
> phpsqlgeocode.html#geocodephp) is the part that im trying to change.
>
>  while ($geocode_pending) {
>     $address = $row["address"];
>     $id = $row["id"];
>     $request_url = $base_url . "&q=" . urlencode($address);
>     $csv = file_get_contents($request_url) or die("url not loading");
>
>     blah blah blah geocode address and update
>     ...
>
>     usleep($delay);
>   }
>
> After that while loop, im trying to look at the record in the table to
> determine if it already has lat/long data, if so, it doesnt need to be
> geocoded right?
>
> this is the code that i came up with, but it doesnt appear to be
> working.
>
>  while ($geocode_pending) {
>         $checkLat = $row["lat"];
>         $checkLng = $row["lng"];
>         if ( $checkLat == "0.000000" ){
>
>     blah blah blah geocode address and update
>     ...
>
>     usleep($delay);
>
> }//end if
> }// end while
>
> ostensibly, the while loop will look at the row and check if there is
> a Lat coordinate, if not, it should geocode the address, otherwise, it
> should move on to the next row.
>
> I know this is more of a php problem, but i thought i would post it
> here as it could improve the efficiency of your service if people
> werent constantly trying to geocode records that didnt need to be.
>
> Any help is greatly appreciated.
>
> Thanks much.
>
> Dave
>
> PS here is the map i am working 
> with.http://sgtclassick.com/gmaps/geocode_locations1.php
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to Google-Maps-API@googlegroups.com
To unsubscribe from this group, send email to 
google-maps-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to