<?php 
//map container
echo '<div id="googleMapContainer" style="width:750px;height:570px;"></div>';
//load Script
echo '<script type="text/javascript" src="modules/Accounts/js/showMap.js"></script>';
echo '<script src="https://maps.googleapis.com/maps/api/js"></script>';
$ids = explode(",",$_REQUEST['uid']);
//get Data
$markers = array();
foreach ($ids as $id) {
    $a = new Account();
    $a->retrieve($id);
    $addr = $a->register_address_street." ".$a->register_address_postalcode." ".$a->register_address_city." ".$a->register_address_country;
    $cor = getCoordinates($addr);
    $tmp = array();
    $tmp['lat'] = $cor[0];
    $tmp['lng'] = $cor[1];
    $tmp['title'] = html_entity_decode(trim($a->name));
    $tmp['info'] = '<a href="index.php?module=Accounts&action=DetailView&record='.$a->id.'" target="new">'.html_entity_decode(trim($a->name)).'</a><br>'.$a->register_address_street.'<br>'.$a->register_address_postalcode.'<br>'.$a->register_address_city.'<br>'.$a->register_address_country;
    $markers[] = $tmp;
}
echo '<input value="'.base64_encode(json_encode($markers)).'" id="googleMapMarkers" type="hidden"></input>';
function getCoordinates($address){
    $address = str_replace(" ", "+", $address); // replace all the white space with "+" sign to match with google search pattern
    $url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$address";
    $response = file_get_contents($url);
    $json = json_decode($response,TRUE); //generate array object from the response from the web
    return array ($json['results'][0]['geometry']['location']['lat'],$json['results'][0]['geometry']['location']['lng']);
}
?>