I'm getting this error when geocoding maps on google maps when it prints the map. when there is a mistake in the address, for example a state in a city, and it is something that is hard to filter for.

11201203205207209211213215217219221
Notice: Undefined offset: 3 in /Library/WebServer/Documents/phoogle1a.php on line 265

I need to fix this error in the class or I need to trap for it so it doesn't print this on the map. The try/catch below is not working but I suspect the problem is the line in the phoogle class on 265. I need to get rid of it one way or the other. I tried turning error reporting off and that didn't work either. I would really like the $value that is the address array to be printed nicely to tell the user to fix it but not the above ugly message.

My code is:

$addr = $_POST['q'];
$addrArray= unserialize($addr);
$addrUnique = array_unique($addrArray);
if(sizeof($addrUnique)>200 )
{
    echo "The maximum addresses are 200 or less  at a time.  You are over the limit.";
	exit;
}

foreach($addrUnique as $key => $value){
	try{
$map->addAddress($value); 
$pointer = $map->addAddress($value);
 print_r($pointer);
 switch($pointer){
 	case(strpos($pointer,"Service Unavailable")):
 		throw new Exception($e="error_503");
        break;
 	case (strpos($pointer, "Undefined offset: 3")):
 		throw new exception($e="undefined_offset");
        break;
         } 
}       
catch (Exception $e){ if ($e ="error_503"){ echo "Please be patient while Google is geocoding."; sleep(6); $map->addAddress($value); } else if($e ="undefined_offset") { echo "There is an error in this address:"."$value"; } } } $map->printGoogleJS();

line 265 of the class is on the ****
It parses the XML addresses for google maps to print. I think it pops the string out and outputs that on the browser. It would be nice if I could fix it so it looks better.

 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--;
 }

    you can simply suppress the message (@), if there's no issue other than the notice (a notice is not an error)

      🙂 thanks, it worked all the notices are gone except one long numerical string, weird, right before the map prints it printed this string. This must be from the parsing class. How can i get rid of that line also? What is it?
      1357911131517192123252729313335373941434547495153555759616365167369717375777981835858789919395979910110310510710911111311511711912112312512712913113313513713914114314514714915115315515715916116316516771691711731751771791811831851879189191193195197199112012032052072092112132152172192211322322522715229231233235237239241243245247249251253255257259261263265267269271273275277279281283

        I figured out what the number is. It is $pointer. I thought $pointer was the $htmlmessage. I have to return another value to get the htmlmessage somehow.

          Write a Reply...