Search code examples
phplatitude-longitude

Get district name from latitude and longitude in php


I have current latitude and longitude, with this how to get district name or code in php. Please help me.


Solution

  • <?php
    $geocode=file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng=48.283273,14.295041&sensor=false');    
    $output= json_decode($geocode);
    echo $output->results[0]->formatted_address;
    ?>
    

    This will get complete address in that you just pass lat long in that url

    Notes: Api Key is needed.