Google Geolocation API - Use longitude and latitude to get address in textbox?

后端 未结 8 608
有刺的猬
有刺的猬 2021-01-31 05:25

I have noticed a lot of information about how to get your location using Google geolocation looks, based on IP address. But I am wondering if and how I could use this service t

8条回答
  •  伪装坚强ぢ
    2021-01-31 05:41

    Google's Maps APIs goes over http, so sending request with get and then parsing the request... It should be possible to do in any language.

    For example, in PHP:

    $ret = file_get_contents("http://maps.google.com/maps/api/geocode/xml?address=" .
                urlencode($address) .
                "&sensor=false" .
                "&key=" . $this->key
        );
    
    $xml = new SimpleXMLElement($ret);
    $error = $xml->status;
    

    Same works for all APIs.

提交回复
热议问题