• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
geo coding

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

#2
[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'];

    }

#3
[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?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.