Welcome Guest, Not a member yet? Register   Sign In
Get coordinates from address
#1

hi i try to get coordinates from openstreetmap
this is my code :
Code:
    public function getCoordinateFromAddress()
    {
     
   
        $address = 'piazza della signoria  ,5, firenze ';

        $geocode = file_get_contents('https://nominatim.openstreetmap.org/search?q='.$address.'&format=json&polygon=1&addressdetails=1');

        $output= json_decode($geocode);

        //print_r($output);
        //die();

        $lat = $output->results[0]->geometry->location->lat;
        $long = $output->results[0]->geometry->location->lng;

   
   }
but with this code i have :

Code:
file_get_contents(https://nominatim.openstreetmap.org/search?q=piazza della signoria ,5, firenze &format=json&polygon=1&addressdetails=1): Failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
How can i solve ?
Reply


Messages In This Thread
Get coordinates from address - by pippuccio76 - 05-02-2023, 12:28 PM
RE: Get coordinates from address - by JustJohnQ - 05-03-2023, 02:23 AM
RE: Get coordinates from address - by pippuccio76 - 05-04-2023, 04:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB