I have some code that prints addrresses on googlemaps. It takes the addressees from an array and sends it to yahooapi to form it into XML. Then calls addAddress function to if they are valid or invalid points. Then it calls an XML parser to put them back into an array of XML to be geocoded. Here is the array and the error messages. It all works. I run about 50-100 addresses through but I get these Undefined offset:3 errors printed on the map.

array(66) { [0]=> string(35) "44502 Loneoak, Lancaster, ca, 93534" [1]=> string(46) "1825 Connecticut Avenue, Washington, DC, 20009" [2]=> string(44) "1 Van de Graaff Drive, Burlington, MA, 01803" [3]=> string(35) "7757 Aburn Road, Concord, OH, 44077" [4]=> string(47) "6070 Parkland Blvd, Mayfield Heights, OH, 44124" [5]=> string(48) "32991 Hamilton Court, Farminton Hills, MI, 48334" [6]=> string(46) "132 Fairgrounds Road, West Kingston, RI, 02892" [7]=> string(36) "2025 E. St NW, Washington, DC, 20006" [8]=> string(37) "8000 Regency Parkway, Cary, NC, 27511" [9]=> string(35) "1109 Hudson Lane, Monroe, LA, 71201" [10]=> string(53) "6841 North Rochester Road, Rochester Hills, MI, 43806" [11]=> string(40) "1608 Godwin Avenue, Lumberton, NC, 28358" [12]=> string(41) "323 South Main Street, Findlay, OH, 45840" [13]=> string(37) "1000 East Main, Plainfield, IN, 46168" [14]=> string(42) "1015 31st Street NW, Washington, DC, 20007" [15]=> string(34) "3236 Grand Ave, Atlanta, WY, 82070" [16]=> string(48) "14250 NW Science Park Drive, Portland, OR, 97229" [17]=> string(50) "49 Old Bloomfield Avenue, Mountain Lakes, NJ, 7046" [18]=> string(45) "50 Mt. Pleasant Avenue, West Orange, NJ, 7052" [19]=> string(49) "7111 Valley Green Road, Fort Washinton, PA, 19034" [20]=> string(42) "2231 E. Camelback Road, Phoenix, AZ, 85016" [21]=> string(35) "29201 Aurora Road, Solon, OH, 44139" [22]=> string(38) "22 E. Mitchell Dr., Phoenix, AZ, 85012" [23]=> string(34) "901 Wilshire Blvd, Troy, MI, 48084" [24]=> string(39) "802 N. Highway, Blue Springs, MO, 64014" [25]=> string(42) "4370 NE Halsey Street, Portland, OR, 97213" [26]=> string(39) "815 N 12th Street, Allentown, PA, 18102" [27]=> string(39) "344 N. McKemy Ave., Chandler, AZ, 85226" [28]=> string(40) "624 Yenne Point Road, Bigfort, MT, 59911" [29]=> string(35) "316 E. Monroe, Southbend, IN, 46601" [30]=> string(41) "2800 Woodlawn Drive., Honolulu, HI, 96822" [31]=> string(42) "9275 SW Peyton Ln., Wilsonville, OR, 97070" [32]=> string(33) "232 Entin Road, Clifton, NJ, 7014" [33]=> string(46) "1009 Commerce Park Drive, Oak Ridge, TN, 37830" [34]=> string(38) "600 College Road, Princeton, NJ, 08540" [35]=> string(38) "610 Champions Drive, Dayton, NV, 89403" [36]=> string(37) "1220 L St. N W, Washington, DC, 20005" [37]=> string(43) "9333 Springboro Pike, Miamisburg, OH, 45342" [38]=> string(36) "2220 W 14th Street, Tempe, AZ, 85281" [39]=> string(44) "1283 Murfreesboro Road, Nashville, TN, 37217" [40]=> string(42) "5427 Mancelona Dr., Grand Blanc, MI, 48439" [41]=> string(36) "200 Technology Way, Butte, MT, 59702" [42]=> string(42) "251 S Willow Avenue, Cookeville, TN, 38501" [43]=> string(38) "4260 E Raines Road, Memphis, TN, 38118" [44]=> string(32) "NBC Plaza, Starkville, MS, 39760" [45]=> string(36) "1155 South 800 East, Orem, UT, 84097" [46]=> string(44) "4 Technology Park Drive, Westford, MA, 01886" [47]=> string(38) "1800 S. Novell Place, Provo, UT, 84606" [48]=> string(41) "2455 North Star Road, Columbus, OH, 43221" [49]=> string(44) "400 N. Broad Street, Philadelphia, PA, 19130" [50]=> string(43) "1634 East Central Blvd., Wichita, KS, 67214" [51]=> string(42) "6399 Shelby View Drive, Memphis, TN, 38134" [52]=> string(36) "809 Hecia Street, Han****, MI, 49930" [53]=> string(42) "9300 Arrowpoint Blvd, Charlotte, NC, 28273" [54]=> string(30) "111 W 5th St, Tulsa, OK, 74103" [55]=> string(41) "7140 South Lewis Avenue, Tulsa, OK, 74136" [56]=> string(40) "3 Corporate Place, Piscataway, NJ, 08854" [57]=> string(39) "11 Lafayette Street, Lebanon, NH, 03766" [58]=> string(51) "7910 Crescent Executive Drive, Charlotte, NC, 28217" [59]=> string(36) "326 SW Broadway, Portland, OR, 97205" [60]=> string(40) "1900 Richmond Road, Cleveland, OH, 44124" [61]=> string(36) "4 Crozerville Road, Aston, PA, 19014" [62]=> string(35) "9 Riverside Road, Weston, MA, 02493" [63]=> string(43) "550 East Timpanogos Circle, Orem, UT, 84097" [64]=> string(35) "100 Crosby Drive, Boston, MA, 01730" [65]=> string(32) "2220 W 14th St, Tempe, AZ, 85281" } addArray

Notice: Undefined offset: 3 in /Library/WebServer/Documents/phoogle2.php on line 272

Notice: Undefined offset: 3 in /Library/WebServer/Documents/phoogle2.php on line 272

Notice: Undefined offset: 3 in /Library/WebServer/Documents/phoogle2.php on line 272

Notice: Undefined offset: 3 in /Library/WebServer/Documents/phoogle2.php on line 272

Notice: Undefined offset: 3 in /Library/WebServer/Documents/phoogle2.php on line 272

Notice: Undefined offset: 3 in /Library/WebServer/Documents/phoogle2.php on line 272

I don't know how to get rid of the error messages and they show up on my map.
The line 272 is on this line in the xml2array function:
$this->arrays[$this->depth][$key]=$this->arrays[$this->depth+1];**
I think there is something wrong with the address but i don't know how to check for it. Does it mean the XML is not well formed? It came from Yahoo. HOw can I check for it? There is a debug function but I can't get it to work. The $css_id is not defined. Does the $css_id come from Yahoo?
thanks,

function addAddress($address,$htmlMessage=null){
     if (!is_string($address)){$apiURL = "http://local.yahooapis.com/MapsService/V1/geocode?appid=JezVqMLV34G_VJeKk_o8kM12GbWa1PiTotJPt6OxwowFgMb73vEJ.VUdXXp92w--&location=";

 $addressData = file_get_contents($apiURL.urlencode($address));


  $results = $this->xml2array($addressData);

    if (empty($results['ResultSet']['Result']['Address'])){
        $pointer = count($this->invalidPoints);
        $this->invalidPoints[$pointer]['lat']= $results['ResultSet']['Result']['Latitude'];
        $this->invalidPoints[$pointer]['long']= $results['ResultSet']['Result']['Longitude'];
        $this->invalidPoints[$pointer]['passedAddress'] = $address;
        $this->invalidPoints[$pointer]['htmlMessage'] = $htmlMessage;

      }else{
        $pointer = count($this->validPoints);
        $this->validPoints[$pointer]['lat']= $results['ResultSet']['Result']['Latitude'];
        $this->validPoints[$pointer]['long']= $results['ResultSet']['Result']['Longitude'];
        $this->validPoints[$pointer]['passedAddress'] = $address;
        $this->validPoints[$pointer]['htmlMessage'] = $htmlMessage;
        $this->validFlag=1;
    }
return($pointer);
}
    die("All Addresses must be passed as a string");
  }

------------xml2array functon--------

       function xml2array($xml){
        $this->depth=-1;
        $this->xml_parser = xml_parser_create();
        xml_set_object($this->xml_parser, $this);
        xml_parser_set_option ($this->xml_parser,XML_OPTION_CASE_FOLDING,0);//Don't put tags uppercase
        xml_set_element_handler($this->xml_parser, "startElement", "endElement");
        xml_set_character_data_handler($this->xml_parser,"characterData");
        xml_parse($this->xml_parser,$xml,true);
        xml_parser_free($this->xml_parser);
        return $this->arrays[0];

}
function startElement($parser, $name, $attrs){
       $this->keys[]=$name; 
       $this->node_flag=1;
       $this->depth++;
 }
function characterData($parser,$data){
   $key=end($this->keys);
   $this->arrays[$this->depth][$key]=$data;
   $this->node_flag=0; 
 }
function endElement($parser, $name)
 {
   $key=array_pop($this->keys);
   if($this->node_flag==1){
     $this->arrays[$this->depth][$key]=$this->arrays[$this->depth+1];
     unset($this->arrays[$this->depth+1]);
   }
   $this->node_flag=1;
   $this->depth--;
 }


}//End Of Class

This is supposed to be a debugger? I don't know what $css_id is.

function showInvalidPoints($displayType,$css_id){
      $total = count($this->invalidPoints);
      if ($displayType == "table"){
        echo "<table id=\"".$css_id."\">\n<tr>\n\t<td>Address</td>\n</tr>\n";
        for ($t=0; $t<$total; $t++){
            echo"<tr>\n\t<td>".$this->invalidPoints[$t]['passedAddress']."</td>\n</tr>\n";
        }
        echo "</table>\n";
        }
      if ($displayType == "list"){
        echo "<ul id=\"".$css_id."\">\n";
      for ($lst=0; $lst<$total; $lst++){
        echo "<li>".$this->invalidPoints[$lst]['passedAddress']."</li>\n";
        }
        echo "</ul>\n";
       }
    }

    I figured it out. I did a var_dump on the class page. It told me each address plotted in the array. I noticed the error messages were attached to addresses. I deleted those addresses and those errors went away.

      Write a Reply...