如何使用地址更新 MapView?

发布于 2024-08-03 10:41:24 字数 341 浏览 1 评论 0原文

我想更新 iPhone 应用程序中的 MapView。使用地理坐标,这很简单。但如果我不知道坐标怎么办?我想使用地址字符串来更新它,就像您在谷歌地图的文本框中输入的那样。

为了提供更多背景信息,在我的应用程序中,MapView 显示了用户的当前位置。检索到位置后,我使用 ReverseGeocoder 将其转换为人类可读的地址,该地址显示在地图下方的 TextView 中。

但位置经常是错误的 - 这个应用程序主要在纽约市使用,而 iPhone GPS 在这里经常不准确(因为高楼大厦?)。在这种情况下,用户可以点击文本视图并输入实际地址。此时,我希望 MapView 使用他们输入的地址进行更新。但对我来说如何实现这一点并不明显。

I want to update a MapView in an iPhone app. Using a geocordinate, this is trivial. But what if I don't know the coordinate? I want to update it using an address string, like you would enter in the text box of google maps.

To give a little more background, in my app a MapView is displayed with the user's current location. After the location is retrieved, I use the ReverseGeocoder to translate it into a human readable address, that is displayed in a TextView below the map.

But the location is often wrong - this app will mainly be used in New York City and the iPhone GPS is often inaccurate here (due to tall buildings?). In this case, the user can tap the text view and put in the actual address. At this point, I want the MapView to update with the address they entered. But it's not obvious to me how to make that happen.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青芜 2024-08-10 10:41:24

iPhone SDK 不提供该功能。您需要使用地理编码服务,例如 Google Geocoding API

Google API 提供 HTTP 服务来查找地理位置。例如,要确定Google总部的位置,您可以查询

http://maps.google.com/maps/geo?q=1600+Amphitheatre+Parkway,+Mountain+View,+CA&output=csv&oe=utf8&sensor=true_or_false&key=your_api_key

您也可以更改结果格式。

The iPhone SDK doesn't provide that functionality. You will need to use a geocoding service like Google Geocoding API.

Google API provides an HTTP service to look up geolocation. For example, to determine the location for Google headquarter, you can query

http://maps.google.com/maps/geo?q=1600+Amphitheatre+Parkway,+Mountain+View,+CA&output=csv&oe=utf8&sensor=true_or_false&key=your_api_key

You can also change the results format.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文