Setting javascript file and its line:
center: new google.maps.LatLng(<?=$lat?>, <?=$lng?>),

Geo coder and pull data from database:
// get address from database
mysql_connect('host', 'user', 'pass');
mysql_select_db('dbname');
$address=str_replace(" ","+",$address);

$url = "http://maps.googleapis.com/maps/api/geocode/xml?address=";.
$address."&sensor=false";

# INITIATE CURL.
$curl = curl_init();

# CURL SETTINGS.
curl_setopt($curl, CURLOPT_URL,"$url");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);

# GRAB THE XML FILE.
$result = curl_exec($curl);

curl_close($curl);

# SET UP XML OBJECT.
$xml = new SimpleXMLElement($result);

$flag=0;
foreach ($xml->result->geometry as $item){
    if($flag==0){
    $lat=$item->location->lat;
    $lng=$item->location->lng;
    $flag=1;
    }
}

setcookie("lat",$lat, time()+3600*24);
setcookie("lng",$lng, time()+3600*24);

header("location: index20.php");

?>
Can be improved this PHP code?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to