Last active
          March 19, 2025 20:18 
        
      - 
      
 - 
        
Save CodeBrauer/984ae92d4c75ff14f087 to your computer and use it in GitHub Desktop.  
    get coordinates from address with google maps api
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| function GMGetCoordinates($address) { | |
| $address = urlencode($address); | |
| $url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false"; | |
| $ch = curl_init(); | |
| $options = array( | |
| CURLOPT_SSL_VERIFYPEER => false, | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_URL => $url, | |
| CURLOPT_HEADER => false, | |
| ); | |
| curl_setopt_array($ch, $options); | |
| $response = curl_exec($ch); | |
| curl_close($ch); | |
| if (!$response) { | |
| return false; | |
| } | |
| $response = json_decode($response); | |
| if ($response->status !== 'OK') { | |
| return false; | |
| } | |
| $lat = $response->results[0]->geometry->location->lat; | |
| $long = $response->results[0]->geometry->location->lng; | |
| return "$lat, $long"; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Its showing following error, Please inform how to fix it:-
{
"error_message" : "You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account",
"results" : [],
"status" : "REQUEST_DENIED"
}