Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Locationcontroller extends CI_Controller{
- public function __construct() {
- parent::__construct();
- $this->load->helper('url');
- }
- public function index(){
- $this->load->view('locationview');
- }
- public function getLocation(){
- $address = $this->input->post('location');
- $coordinates = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=true');
- $coordinates = json_decode($coordinates);
- // echo 'Latitude:' . $coordinates->results[0]->geometry->location->lat;
- // echo 'Longitude:' . $coordinates->results[0]->geometry->location->lng;
- $lat = $coordinates->results[0]->geometry->location->lat;
- $lng = $coordinates->results[0]->geometry->location->lng;
- // $data=array('address'=> $this->input->post('address'));
- echo $lat.' '.$lng;
- }
- }
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement