Skip to main content

Posts

Showing posts with the label GoogleMap

Distance between two addresses using Google Maps API and PHP

We can easily calculate distance between two addresses using Google Maps API and PHP . We have created a simple PHP function for getting distance between two addresses. getDistance() function grouped all functionalities together and it accepts three parameters. $addressFrom – Required. Pass the from address. $addressTo – Required. Pass the to address. $unit – Optional. Pass the first letter of desire unit. Default is Mile. ( K – kilometre, N – Nautical Mile) getDistance() function is given below. /** * * Author: CodexWorld * Function Name: getDistance() * $addressFrom => From address. * $addressTo => To address. * $unit => Unit type. * **/ function getDistance($addressFrom, $addressTo, $unit){ //Change address format $formattedAddrFrom = str_replace(' ','+',$addressFrom); $formattedAddrTo = str_replace(' ','+',$addressTo); //Send request and receive json data $geocodeFrom = file_get_contents('http://maps.googl...

How to Get Latitude and Longitude from Image in PHP

Geographical location can be tagged with the photograph by geotagging. Generally, the latitude and longitude are assigned to the image to geotagged photograph. Geotagging is done by two ways, automatic or manual. If geolocation is enabled, the geotagging is automatically done by the device. Alternatively, you can tag geodata to the photo manually. In this tutorial, we will show you how to retrieve geolocation information from the image in PHP. There is an easy way to get Geotag data from the image using PHP . You can get the location where picture was taken using PHP. In our example script, the latitude and longitude will be retrieved from the image in PHP. This latitude and longitude can be used to show the location of the image on Google map. Get Latitude and Longitude from Image The exif_read_data() function in PHP, reads the EXIF headers from an image file. We will use exif_read_data() function to get the GPS data from image. For better usability, we’ll group all code tog...