Xcode iOS 4.2.1 ->给地图查看地址以显示图钉?
可能的重复:
使用 CLGeocoder 的转发地理编码示例
我有一个充满姓名及其地址的 plist。我希望我的 iOS 应用程序在地图视图上显示一个带有他所选择的人的地址的图钉。我可以将地址导入到地图视图并获取图钉吗?又如何?谢谢。
Possible Duplicate:
Forward Geocode Example using CLGeocoder
I have a plist full of names and their adrresses. I want my iOS app to show on a map view a pin with the address of the person he has selected. Can I import the address to map view and get a pin? And how?? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 CLGeocoder 类将地址转换为纬度/经度坐标:
使用 CLGeocoder 的正向地理编码示例
您拥有的地址越准确,结果就越好,因此使用准确的地址,您应该获得非常准确的点。
Use the CLGeocoder class to convert addresses into lat/long coordinates:
Forward Geocode Example using CLGeocoder
The more accurate address you have, the better the result should be so with exact addresses you should get very accurate points.
另一种选择是使用 Google 的地理编码网络服务,只需将地址字符串传递给此函数,您将获得一个 CLLocationCooperative2D,其中包含纬度和坐标。经度。
现在它获取第 0 个索引的位置,这是最接近的匹配结果。注销结果以查看来自 Google 的 JSON 响应。
Another option is to use Google's geocoding web service, simply pass the address string to this function and you will get an CLLocationCoordinate2D which contains a latitude & longitude.
Right now it grabs the location at the 0th index, which is the closest matching result. Log out the result to see the JSON response from Google.
这就是所谓的正向地理编码,并且没有内置 API 可以为您执行此操作。您需要使用外部服务,使用哪一个实际上取决于您的应用程序。
我为此使用了谷歌的服务。 http://code.google.com/apis/maps/documentation/geocoding/
这是一个非常简单的 API,但根据您的应用程序许可证有限制。我知道还有一些其他服务可以实现此目的,但我将其作为练习留给您。
This is whats known as Forward Geocoding, and there is no built in API to do this for you. You need to use an external service, which one you use really depends on your app.
I have used Google's service for this. http://code.google.com/apis/maps/documentation/geocoding/
It is a very simple API, but has restrictions based on your app's license. I know there are a couple other services for this, but I'll leave that as an exercise to you.