Showing posts with label Google API. Show all posts
Showing posts with label Google API. Show all posts

Thursday, 20 March 2014

how to get latitude and longitude from address in php

              you can easily find latitude and longitude using address.here i am using Google Maps API to get latitude & longitude using php.just copy below code and run this code to you can easily find latitude or longitude of any address in the world.



HTML Code :

<html>
<head><title>Simple</title></head>
<body>
<br />
    <form name="frm" id="frm" method="post" enctype="multipart/form-data" action="get_lati_longi.php">
        Type Your Location : <input type="text" name="myaddress" />
        <input type="submit" value="get lati longi">
    </form>
<br />

PHP Code :

<?php

if(isset($_POST['myaddress'])){
$myaddress = urlencode($_POST['myaddress']);
$url = "http://maps.googleapis.com/maps/api/geocode/json?address=$myaddress&sensor=false";
$getmap = file_get_contents($url); 
$googlemap = json_decode($getmap);

foreach($googlemap->results as $res){
     $address = $res->geometry;
     $latlng = $address->location;
     $formattedaddress = $res->formatted_address;


}
echo "Latitude: ". $latlng->lat ."<br />". "Longitude:". $latlng->lng; 
}
?>

</body>
</html>






Monday, 17 March 2014

How to create Google API?

in this tutorial i have explained that how to create Google API. a google api is very useful for web developers. you can use multiple google api and get more usefull information from google related your development area.


there are given below step fllow and create google api.

1. Visit https://console.developers.google.com/

2.Click on Create Project Button.



3.Fill out your Project Details.



4.Click on the Create Button

5.You can see the Activities happening on the bottom of the page.



6.When your project will  be created,then click on the APIs and auth Button from the left sidebar



7.Enable the APIs which you needed to get data from google.

  

8.Click on the Credentials Button from the left sidebar




9.Click on the CREATE NEW CLIENT ID Button.



10.Select Web Application from Application type
      Then,Fill out other required information .
      Then, Click on the Create Client ID Button.
 

After Creating new Client ID,You will get your Client ID,Client Secret and Redirect URI.