Koren
Posts: 83
|
Posted: 03/12/2013, 7:55 PM |
|
I am trying to get the longitude and latitude from google maps and insert it into the database using a hidden field that is populated with the info when keyed into an editable grid.
I am able to get the data just fine and display it in a BeforeShowRow hidden field and can update esisting rows, but i need to have rows newly entered get the data and insert it into the database when the keyed address information is inserted.
Any direction would be greatly appreciated!
Thank You! Thank You!
Koren
P.S.
Project created in Code Charge Studio 4.3
In BeforeBuildUpdate for the Editable Grid....
global $DBConnection1;
global $addresses,$latlng,$myaddress;
$myaddress = $Container->address_st->GetValue();
$myaddress .= " ";
$myaddress .= $Container->state->GetValue();
$myaddress .= " ";
$myaddress .= $Container->zip->GetValue();
$url = "http://maps.googleapis.com/maps/api/geocode/json?address=".str_replace(" ","+",$myaddress)."&sensor=false";
$getmap = file_get_contents($url);
$googlemap = json_decode($getmap);
foreach($googlemap->results as $res){
$address = $res->geometry;
$latlng = $address->location;
$formattedaddress = $res->formatted_address;
$Container->DataSource->lat_id->SetValue($latlng->lat);
$Container->DataSource->lng_id->SetValue($latlng->lng);
}
|