搜索附近的汽车修理 (搜索附近的汽车清洗)
长沙洗浴
04-16
阅读:51
评论:0
![](/gg/hf11.gif)
![搜索附近的汽车修理 (搜索附近的汽车清洗)](https://tgirlmeat.com/thumb/20240416224851_15310.jpg)
status === 'OK') {// 从地址获取纬度和经度$lat = $geocode_response->results[0]->geometry->location->lat;$lng = $geocode_response->results[0]->geometry->location->lng;// API 密钥和搜索 URL$api_key = 'AIzaSyD6p6Zi-Wm03M48_hL3yFyf3Xel_oG0X8c';$search_url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=' . $lat . ',' . $lng . '&radius=5000&type=car_repair|car_wash&key=' . $api_key;// 获取搜索结果$search_response = json_decode(file_get_contents($search_url));if ($search_response->status === 'OK') {// 将结果循环显示foreach ($search_response->results as $result) {echo '
';echo '
';}} else {echo '
' . $result->name . '
';echo '
' . $result->formatted_address . '
';echo '
' . $result->formatted_phone_number . '
';echo '
' . $result->website . '
';echo '
很抱歉,没有找到任何结果。
';}} else {echo '很抱歉,无法找到给定的地址或邮政编码。
';}}?>版权声明
本文仅代表作者观点,不代表长沙桑拿立场。
本文系作者授权发表,未经许可,不得转载。