jannik
10/12/2017 - 8:04 AM

Get provincie from LAT/LONG. Of andere...

Get provincie from LAT/LONG. Of andere...

<?php

    $regio;

    $json = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng='.$lat.','.$lng.'&sensor=false');
    $obj = json_decode($json);
    $regio = $obj->results[0]->address_components[3]->long_name;
    if($regio === 'Belgium'){
        $regio = $obj->results[0]->address_components[2]->long_name;
    }

?>