I'm trying to get the $pointer return value from the function but I'm getting an error. Changes to the function were only adding the vars $validPoints, $invalidPoints and $validFlag. The error is "unexpected T_Public". Does this mean I need a constructor? Would I instantiate the map class or just the addAddress function?
Is the client part right? It seems wrong to call $map->addAddress($value) and then call $map->addAddresss($value) again and assign it to the var $pointer but I need both lines. The first to loop through the list and add the addresses to be plotted to the $map class and the second is to get the returned pointer value from the addAddress function.
thanks,
foreach($addrArray as $key => $value){
$map->addAddress($value);
$pointer = $map->addAddress($value);
if($map->validFlag){
$html = $map->validPoints[$pointer]['htmlMessage'];
}else {
$html = $map->invalidPints[$pointer]['htmlMessage'];
}
$map->printGoogleJS();
}
-----------function -----
function addAddress($address,$htmlMessage=null){
if (!is_string($address)){
die("All Addresses must be passed as a string");
}
$apiURL = "http://local.yahooapis.com/MapsService/V1/geocode?appid=DoO9dXzV34FMVcI3aXjfoWLtUj_UBTBW4ltfKXiEDnXMnbm2DJ__79_Aw.n3EA--&location=";
$addressData = file_get_contents($apiURL.urlencode($address));
public $validFlag;
public $validPoints;
public $invalidPoints;
$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;
$this->$validFlag=1;
}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=0;
}
return $pointer;
}
}