菜鸟教程小白 发表于 2022-12-12 16:16:06

ios - 在 Google Places 自动完成 iOS api 中包含距离


                                            <p><p>我正在尝试实现一个看起来像谷歌地图 iOS 应用程序的自动完成框。在该应用程序中,建议按距离排序,左侧的标签显示距离。我认为他们正在使用 Places Autocomplete API,但我无法让它返回距离。是否有某种标志可以用来让 Google Places 的自动完成功能返回设备的距离?我是否使用了错误的 API/函数?</p>

<p>我目前正在使用以下功能:</p>

<blockquote>
<p>autocompleteQuery:bounds:filter:callback:</p>
</blockquote>

<p>文档在这里:</p>

<blockquote>
<p><a href="https://developers.google.com/places/ios-api/autocomplete" rel="noreferrer noopener nofollow">https://developers.google.com/places/ios-api/autocomplete</a></p>
</blockquote></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您无法直接在自动完成响应中获取距离信息。</p>

<p>我建议使用 <a href="https://developers.google.com/places/ios-api/reference/interface_g_m_s_places_client.html#a0858545fb8ff829594d01f5925381030" rel="noreferrer noopener nofollow">lookUpPlaceID</a> 对响应中的每个位置执行详细信息请求.然后您可以访问<a href="https://developers.google.com/places/ios-api/reference/interface_g_m_s_place.html#a3dc43865df0de69b6b1203a15a745efc" rel="noreferrer noopener nofollow">coordinate</a>返回地点的字段来计算距离。</p>

<p>如果您异步执行此操作,您可以在返回时使用自动完成预测更新您的 UI,然后在详细信息请求完成后再次使用距离更新它。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 在 Google Places 自动完成 iOS api 中包含距离,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/32549214/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/32549214/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 在 Google Places 自动完成 iOS api 中包含距离