Distance Calculator Kese Bnaye -Google Distance Matrix Api




Hello Friends Ajj me apko btaunga ki kis trah ham distance check kar sakte hai Php Ka Use Karke-



Yanha ham file_get_content ka use karke Distance Pata karege Googlle Metrix distance api ka use karke.



Sabse pehle ek form create kar lijiye janha ham souce  and destination address enter karege.
Demo-Distance Calculator Between Two Place


Index.php




        <form action="Distance.php" method="post">







       Origin: <input type="text" name="o"  required> <br><br>



        Destination: <input type="text" name="d"  required> <br><br>



            <input type="submit" value="Calculate" name="submit"> <br><br>







        </form>




Distance.php




        <?php



            if(isset($_POST['submit'])){



            $origin = $_POST['o'];



                                    $destination = $_POST['d'];



            $api = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=".$origin."&destinations=".$destination."&key=
Enter You Api Key Here");//enter your api key here



            $data = json_decode($api);



        ?>





            <label><b>Distance: </b></label> <span><?php echo ((int)$data->rows[0]->elements[0]->distance->value / 1000).' Km'; ?></span> <br><br>



            <label><b>Travel Time: </b></label> <span><?php echo $data->rows[0]->elements[0]->duration->text; ?></span>


   <?php } ?>

Ab aap  https://console.developers.google.com/



Open kijiye or  ek new project create kijiye



yanha Distance likhkar search kijiye ab apke pass



Distance matrix api ka option ayega aap ise Enable kar lijiye



yanha ab aap credentianl par click kijiye yanha apko ek api key milegi us api key ko is code me api key ki jgah enter karke code ko save kar dijiye.



Is parkar aap google api ka use karke distance check/calculate kar sakte ho
.

Thank You
Team Gajabwap Web In Hindi

Previous
Next Post »

1 comments:

Click here for comments
Unknown
admin
21 June 2018 at 07:07 ×

thanks bro bhut ache Post hai keep it Aap. it is very helpful

Congrats bro Unknown you got PERTAMAX...! hehehehe...
Reply
avatar
Thanks for your comment