CodeIgniter Forums
geo coding - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: geo coding (/showthread.php?tid=11130)



geo coding - El Forum - 08-27-2008

[eluser]PHPraja[/eluser]
does any one know the procedure for implementing geo coding using google api in CI environment?


geo coding - El Forum - 08-27-2008

[eluser]ehicks727[/eluser]
I got frustrated with Google and just use Yahoo now. You can geocode up to 5000 per day. You need to get an appid key first. http://developer.yahoo.com/maps/rest/V1/geocode.html

$a = address
$c = city
$s = state
$z = zipcode

Code:
function gcode($a, $c, $s, $z) {
        if (strpos($a, 'PO Box') > -1) return false;
        
        $url =     'http://local.yahooapis.com/MapsService/V1/geocode?appid=[your appid here]'.
                '&street;='.urlencode($a).
                '&city;='.urlencode($c).
                '&state;='.$s.
                '&zipcode;='.$z.
                '&output=php';

        $response = file_get_contents($url);

        if ($response === false) return false;
            //die('Request failed');

        $phpobj = array_change_key_case(array_shift(array_shift(unserialize($response))));

        return $phpobj;

        //echo $phpobj['latitude'].'<br />';
        //echo $phpobj['longitude'];

    }



geo coding - El Forum - 01-11-2010

[eluser]watanuki[/eluser]
Newbie need help please...

I want to translate location into longitude and latitude, I have tried to modify my code as mention by ehicks727, but the result still negative.

here is my code:

Code:
function locate(){
$place=$_REQUEST['place'];
if($place){
       $data=$this->gcode($place);
    $this->load->view('map/show_map',$data);
    $this->load->view('footer_view');
    }else{
      $this->load->view('map/map_err');
      $this->load->view('footer_view');
        }
    }

function gcode($location) {
        $url = 'http://local.yahooapis.com/MapsService/V1/geocode?appid=[my_appid]'.
                '&location;='.rawurlencode($location).
                '&output=php';
        $response = file_get_contents($url);
        if ($response === false) return false;
            //die('Request failed');
        $phpobj = array_change_key_case(array_shift(array_shift(unserialize($response))));
        return $phpobj;
    }

if I echo $data['longitude'] and $data['latitude'], it's always empty.. Any suggestion?