简体   繁体   English

如何使用 Flutter 上的 placeId 获取 Google Place?

[英]How to get a Google Place using a placeId on Flutter?

I'm trying to find a function that would allow me to get a Google Place only using a placeId (and the apiKey of course).我正在尝试找到一个函数,该函数允许我仅使用 placeId(当然还有 apiKey)来获取 Google Place。

I found the function GeoDataClient.getPlaceById(placeId) but unfortunately this doesn't seem to be available on Flutter.我找到了 GeoDataClient.getPlaceById(placeId) 函数,但不幸的是,这在 Flutter 上似乎不可用。 I am currently using the flutter_google_places dart package but am open to using something different if necessary.我目前正在使用 flutter_google_places dart 包,但如果需要,我愿意使用不同的东西。

I can't find one.我找不到一个。 It seems like something of a large gap in the ecosystem -- if you store a Google Place ID in your local database, you should be able to convert that into a place name and a location when you reload it.生态系统中似乎存在很大差距——如果您将 Google Place ID 存储在本地数据库中,您应该能够在重新加载时将其转换为地名和位置。

The iOS equivalent of GeoDataClient is the Places SDK for iOS: https://developers.google.com/places/ios-sdk/intro . GeoDataClient的 iOS 等效GeoDataClient是适用于 iOS 的 Places SDK: https : //developers.google.com/places/ios-sdk/intro

I may write a plugin for this and add it to pub.dev.我可能会为此编写一个插件并将其添加到 pub.dev。 Unless you've found a better solution since you posted this question, this seems like the best available approach at the moment.除非您在发布此问题后找到了更好的解决方案,否则这似乎是目前最好的方法。

With that said, however, connecting to the Google Places SDK requires a network connection, so if you want optimal performance, you should try to keep invocations of the SDK bridge to a bare minimum, and ideally keep place details in a local SQLite database.然而,话虽如此,连接到 Google Places SDK 需要网络连接,因此如果您想要获得最佳性能,您应该尽量将 SDK 网桥的调用保持在最低限度,最好将地点详细信息保存在本地 SQLite 数据库中。 This way, users will only be invoking the SDK bridge after loading the app on a new device.这样,用户只会在新设备上加载应用程序后调用 SDK 桥接器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM