<tfoot id='5Ao1f'></tfoot>

  1. <i id='5Ao1f'><tr id='5Ao1f'><dt id='5Ao1f'><q id='5Ao1f'><span id='5Ao1f'><b id='5Ao1f'><form id='5Ao1f'><ins id='5Ao1f'></ins><ul id='5Ao1f'></ul><sub id='5Ao1f'></sub></form><legend id='5Ao1f'></legend><bdo id='5Ao1f'><pre id='5Ao1f'><center id='5Ao1f'></center></pre></bdo></b><th id='5Ao1f'></th></span></q></dt></tr></i><div id='5Ao1f'><tfoot id='5Ao1f'></tfoot><dl id='5Ao1f'><fieldset id='5Ao1f'></fieldset></dl></div>

    • <bdo id='5Ao1f'></bdo><ul id='5Ao1f'></ul>

    <small id='5Ao1f'></small><noframes id='5Ao1f'>

    <legend id='5Ao1f'><style id='5Ao1f'><dir id='5Ao1f'><q id='5Ao1f'></q></dir></style></legend>
    1. 使用php、API自动获取经纬度

      时间:2023-09-25

          <tbody id='6ofP9'></tbody>

            <bdo id='6ofP9'></bdo><ul id='6ofP9'></ul>
            <i id='6ofP9'><tr id='6ofP9'><dt id='6ofP9'><q id='6ofP9'><span id='6ofP9'><b id='6ofP9'><form id='6ofP9'><ins id='6ofP9'></ins><ul id='6ofP9'></ul><sub id='6ofP9'></sub></form><legend id='6ofP9'></legend><bdo id='6ofP9'><pre id='6ofP9'><center id='6ofP9'></center></pre></bdo></b><th id='6ofP9'></th></span></q></dt></tr></i><div id='6ofP9'><tfoot id='6ofP9'></tfoot><dl id='6ofP9'><fieldset id='6ofP9'></fieldset></dl></div>
            <tfoot id='6ofP9'></tfoot>
          • <small id='6ofP9'></small><noframes id='6ofP9'>

                <legend id='6ofP9'><style id='6ofP9'><dir id='6ofP9'><q id='6ofP9'></q></dir></style></legend>
                本文介绍了使用php、API自动获取经纬度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                在我的一个 php 应用程序中,我必须从地址中找出该地点的纬度和经度.

                In one of my php applications I have to find out the latitude and longitude of the place from address.

                我试过这个代码:

                $json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false&region=$region");
                $json = json_decode($json);
                
                $lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
                $long = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'};
                

                但它显示以下错误:

                警告:file_get_contents(http://maps.google.com/maps/api/geocode/json?address=technopark, Trivandrun, kerala,India&sensor=false&region=IND) [function.file-get-内容]:无法打开流:HTTP 请求失败!第 4 行 D:Projectslon.php 中的 HTTP/1.0 400 Bad Request

                Warning: file_get_contents(http://maps.google.com/maps/api/geocode/json?address=technopark, Trivandrun, kerala,India&sensor=false&region=IND) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in D:Projectslon.php on line 4

                请帮我解决这个问题.

                推荐答案

                使用 curl 而不是 file_get_contents:

                $address = "India+Panchkula";
                $url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false&region=India";
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                $response = curl_exec($ch);
                curl_close($ch);
                $response_a = json_decode($response);
                echo $lat = $response_a->results[0]->geometry->location->lat;
                echo "<br />";
                echo $long = $response_a->results[0]->geometry->location->lng;
                

                这篇关于使用php、API自动获取经纬度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:用于实时聊天应用程序的 HTML5 Websockets? 下一篇:谷歌地图:是多边形内的纬度/经度吗?

                相关文章

                最新文章

                <i id='6C3D6'><tr id='6C3D6'><dt id='6C3D6'><q id='6C3D6'><span id='6C3D6'><b id='6C3D6'><form id='6C3D6'><ins id='6C3D6'></ins><ul id='6C3D6'></ul><sub id='6C3D6'></sub></form><legend id='6C3D6'></legend><bdo id='6C3D6'><pre id='6C3D6'><center id='6C3D6'></center></pre></bdo></b><th id='6C3D6'></th></span></q></dt></tr></i><div id='6C3D6'><tfoot id='6C3D6'></tfoot><dl id='6C3D6'><fieldset id='6C3D6'></fieldset></dl></div>

                <small id='6C3D6'></small><noframes id='6C3D6'>

                  1. <legend id='6C3D6'><style id='6C3D6'><dir id='6C3D6'><q id='6C3D6'></q></dir></style></legend>
                    <tfoot id='6C3D6'></tfoot>
                      <bdo id='6C3D6'></bdo><ul id='6C3D6'></ul>