Usage:
You have to access the above getAddress[]
function like this,
The php script will output the location as a human-readable address.
API Key:
Without API Key, you're requests credits per day will be very limited. In order to use the API key in each of your requests, you must first activate the Google Maps API and obtain the authentication credentials for it.
Log in to your Google account, go to the API console, activate the 'Google Maps Geocoding API' and get an 'API_KEY'.
Then you can use this key in the url every time you send a request to the api in this way,
//maps.google.com/maps/api/geocode/json?latlng=$latitude,$longitude&key=API_KEY;
Please note that the sensor
param is deprecated in the latest versions of the API. Therefore, it is no longer necessary to attach it with the request URL.
Read Also:
- Get YouTube Video Title, Description and Thumbnail in PHP
- Store and Retrieve Images from MySQL Database using PHP
That explains about getting location from latitude and longitude in php using Google Maps Geocoding API. You can use this address info to place a marker on Google Maps. I hope you like this tutorial. If you find this post useful, please share it in your social circle.