function getSaving($source, $destination) { $data = getDistance($source, $destination); $fare = calculateFare($data["distance"]); $duration = minToHours(calculateDuration($data["distance"])); $start_date = "06/03/2015"; $end_date = "09/03/2015"; $geoCordinates = get_lat_long($destination); $hotelPrice = getStayzillahotel($geoCordinates[0], $geoCordinates[1], $start_date, $end_date); $Price = $hotelPrice->hotels[0]->rawPrice; $stayzillaSource = $hotelPrice->hotels[0]->address; $data_User = array("distance" => $data["distance"], "duration" => $duration, "cabFare" => $fare); $stayzillaData = getDistance($stayzillaSource, $destination); $stayZillaDistance = number_format((double) $hotelPrice->hotels[0]->distanceFromLatLong / 1000, 2, '.', ''); $stayzillafare = calculateFare($stayZillaDistance); $stayzillaDuration = minToHours(calculateDuration($stayZillaDistance)); $data_stayzilla = array("distance" => $stayZillaDistance . " km", "duration" => $stayzillaDuration, "cabFare" => $stayzillafare, "hotelFare" => $Price, "hotelData" => $hotelPrice->hotels[0]); $responceData = array(); $responceData["user"] = $data_User; $responceData["stayzilla"] = $data_stayzilla; return json_encode($responceData); }
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 */ print json_encode($coords, JSON_FORCE_OBJECT);
function get_walkscore($address) { require_once "WalkScore.php"; $l_temp = get_lat_long($address); $w = new WalkScore('dbd8b3f251a2ea4b4a6be60beae80642'); $w_options = array('address' => $address, 'lat' => $l_temp['lat'], 'lon' => $l_temp['long']); $score = $w->WalkScore($w_options)->walkscore; return $score; }
<?php include_once 'functions.php'; require_once "WalkScore.php"; $temp = get_lat_long('1119 208th Ave S, Seattle, WA'); echo $temp['lat']; echo $temp['long']; $w = new WalkScore('dbd8b3f251a2ea4b4a6be60beae80642'); // WalkScore example // Example data from http://www.walkscore.com/professional/api.php $options = array('address' => '1119 208th Ave S, Seattle, WA', 'lat' => 47.416022, 'lon' => -122.320273); var_dump($options); printf("\n"); //printf("WalkScore for %s:\n", $options['address']); //$score = $w->WalkScore($options)->walkscore; //var_dump($w); print_r($w->WalkScore($options));
public function get_lat_long() { //$address = $this->input->post('address'); $address = 'L.P. Savani School, L.P.Savani, Surat, Gujarat, India'; echo get_lat_long($address); }
function update_pelanggan($id) { if ($this->session->userdata('is_login') == TRUE) { $user = $this->session->userdata('data_user'); $data['pengguna'] = $user; $data['imgPegawai'] = $this->m_beranda->getImage($user->id_pegawai); //hanya diberikan kepada kepala teknisi, karywan, dan teknisi if ($data['pengguna']->jabatan_pegawai == 'KEPALA TEKNISI' || $data['pengguna']->jabatan_pegawai == 'KARYAWAN' || $data['pengguna']->jabatan_pegawai == 'TEKNISI') { $data['title_sub1'] = "<span class='fa fa-tags'></span> Edit Pelanggan"; $data['title_sub2'] = ""; $data['title'] = "Data"; $data['title2'] = "Pelanggan"; $data['active'] = "Edit Pelanggan"; $data['type'] = 'EDIT'; $data['action'] = 'data/update_pelanggan/' . $id; $data['link_back'] = anchor('data/pelanggan', 'Kembali Ke Data Pelanggan', array('class' => 'back')); $data['pelanggan'] = $this->m_data->getpelangganById($id); $pelanggan = $data['pelanggan']; foreach ($pelanggan as $p) { # code... $data['dataJalur'] = $this->m_data->dataJalurNotById($p->id_dp); } $getPelanggan = $this->m_data->getPelangganById($id); if ($getPelanggan[0]->status_pelanggan == 'ON') { if ($this->input->post('submit')) { $lokasi = get_lat_long($this->input->post('alamat_pelanggan')); $map = explode(',', $lokasi); $mapLat = $map[0]; $mapLtg = $map[1]; $arr_dataPelanggan = array('id_dp' => $this->input->post('id_dp'), 'nama_pelanggan' => strtoupper($this->input->post('nama_pelanggan')), 'alamat_pelanggan' => strtoupper($this->input->post('alamat_pelanggan')), 'lat_pelanggan' => $mapLat, 'ltg_pelanggan' => $mapLtg, 'telp_hp_pelanggan' => $this->input->post('telp_hp_pelanggan'), 'telp_rumah_pelanggan' => $this->input->post('telp_rumah_pelanggan')); $this->m_data->updatePelanggan($id, $arr_dataPelanggan); redirect('data/pelanggan'); } else { $this->template->load('template/template_view', 'data/v_data_iepelanggan_bar', $data); } } else { redirect('errors/page_missing'); } } else { redirect('errors/page_missing'); } } else { redirect('login/try_login'); } }