Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Server Side Google Map API v3 Integration

I am trying to accomplish a two step task on the server side using Google Map API v3 rather than on the client side but have not found much documentation as to how to accomplish this. So I was wondering if anyone here can help or guide me in the right direction.

The 1st step is getting the geo-code location of an address using PHP. I think I have figured this out and that is by making a curl call to http://maps.google.com/maps/api/geocode/json?sensor=false&address= and processing the JSON response. Once I have the geo-codes, I store them in my database.

The 2nd step is finding random addresses in a specific radius of the address in 1st step. This I cannot seem to find how to do in the server side.

Any help or guidance would be truly appreciated.

like image 490
Mercury Terminal Avatar asked Oct 08 '22 00:10

Mercury Terminal


1 Answers

  1. Easiest way

    $url = 'http://maps.google.com/maps/api/geocode/json?sensor=false&address=' . urlencode($address);     
    $data = json_decode(file_get_contents($url), true); // insert in the database
    
  2. Searching with the given radius and center point (lat, lng): https://developers.google.com/maps/articles/phpsqlsearch

like image 116
hamczu Avatar answered Oct 13 '22 11:10

hamczu