title: Get nearby locations using google places api in php/codeigniter
body: <p>I have to fetch results of nearby locations within 2 km of my given latitude/longitude values. Have to do it using Google Places API. Details go here:</p>
  
  <p><a href="http://code.google.com/apis/maps/documentation/javascript/places.html" rel="nofollow">http://code.google.com/apis/maps/documentation/javascript/places.html</a></p>
  
  <p>They have provided a sample code in javascript. But I need to have this in php. Can anyone give me any idea how may I achieve it? Or how may I use this same javascript code in my php controller class? [I am using code igniter framework]. I have been stuck on this issue for so many hours. It will be great if someone can provide a sample php code. Highly appreciate any assistance.</p>
  
  <p>Here is the code of my controller class:</p>
  
  <pre><code>&lt;?php
  
  class Welcome extends CI_Controller {
      public function index()
      {
  
      $config = "";
  
      //$this-&gt;load-&gt;library('googlemaps');
          $this-&gt;load-&gt;library('googlemaps');
  
      $config['center'] = '37.4419, -122.1419';
      $config['zoom'] = 'auto';
      $config['places'] = TRUE;
      $config['placesLocation'] = '37.4419, -122.1419';
      $config['placesRadius'] = 200; 
      $this-&gt;googlemaps-&gt;initialize($config);
  
      $data['map'] = $this-&gt;googlemaps-&gt;create_map();
  
      $this-&gt;load-&gt;view('map_view', $data);
      }
  }
  ?&gt;
  </code></pre>
  
  <p>This is the error I encounter while I try to run the above code:</p>
  
  <p>Fatal error: Using $this when not in object context in /Applications/XAMPP/xamppfiles/htdocs/ciplaces/application/controllers/mapcontroller.php on line 9</p>
  
  <p>I am accessing my code using this url:</p>
  
  <p><a href="http://localhost/ciplaces/index.php/mapcontroller" rel="nofollow">http://localhost/ciplaces/index.php/mapcontroller</a></p>
  
  <p>Thanks </p>