*/
function get_lat_long($address, $count)
{
    $address = str_replace(" ", "+", $address);
    $json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address={$address}&sensor=true");
    $json = json_decode($json);
    if ($json->{'status'} == "OK") {
        $lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
        $long = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'};
    }
    return array($lat, $long, $count);
}
/* Calling formstack API getSubmissions for a static form Id */
try {
    //$forms = $wrapper->getForms();
    $subs = $wrapper->getSubmissions($formId, $encryptionPassword = '', $minTime = '', $maxTime = '', $searchFieldIds = array(), $searchFieldValues = array(), $pageNumber = 1, $perPage = 25, $sort = 'DESC', $data = true, $expandData = true);
} catch (Exception $e) {
    echo $e->getCode();
}
/* 
 * For each submission record, adding default area of Mysuru, Karnaraka.
 * Getting the lat and log from Google Map API based upon this address.
 */
foreach ($subs as $key => $value) {
    $temp = $value->data->{'36417370'}->value->address;
    $temp2 = $value->data->{'36417370'}->value->address2;
    $add_rec = $temp2 . "," . 'Mysuru' . "," . 'Karnataka' . "," . 'India';
    $coords[$count] = get_lat_long($add_rec, $count);
    $count++;
}
/* Returning json array of all the locations to use in google map */
 /**
  * Utility method to get a editable submission id
  *
  * @return  int $submissions[0]->id The id of the first submission found
  */
 private function getEditableSubmissionId()
 {
     $wrapper = new FormstackApi(ACCESS_TOKEN);
     $submissions = $wrapper->getSubmissions(DELETE_SUBMISSION_FORM, '', '', '', array(), array(), 1, 100, 'ASC');
     return $submissions[0]->id;
 }