查找地图视图的地址
我目前在 iPhone 应用程序中显示了一个地图视图。我想知道是否有办法放置地址字段,允许用户输入地址,然后让地图重新以该特定地址的坐标为中心?
希望有任何帮助,谢谢。
I currently have a mapView being displayed in an iPhone app. I'm wondering if there is a way to put an address field, allow the user to enter an address, and then have the map re-center over the coordinates of that particular address?
Would appreciate any help, thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这绝对有可能。但是,您需要使用第 3 方 api 进行 google 正向地理编码(地址 --> 纬度/经度)。
http://blog.sallarp.com/ipad-iphone-forward- geocoding-api-google/
转发地址字符串的地理编码并使用注释将其放置在地图上。
Yes, it's definitely possible. However, you will need to use a 3rd party api for the google forward geocoding (address --> lat/long).
http://blog.sallarp.com/ipad-iphone-forward-geocoding-api-google/
Forward geocode the address string and use annotation to place it on the map.
当然有办法做到这一点。做到这一点的方法是有一个 UITextField,用户在其中输入地址和一个按钮,当按下该按钮时,将通过网络请求发送到 google 地图 api,该 api 返回与该地址相关的实际经度/纬度,然后地图视图可以重新以那些在该点放置图钉的坐标为中心。
编辑:
上面解释的是我的实现方式。除了 UiTextField 和按钮,您还可以使用 UISearchBar,这里有一个很好的链接可以帮助您继续。
如何使用 UISearchBar 搜索 MKMapView?
There certainly is a way to do that. The way to do this would be to have a UITextField in which the user enters the address and a button, which when pressed sends over a web request to google map api which returns the actual longitude/latitude pertaining to the address and then the mapview can be re centered to those coordinates dropping a pin at that point.
EDIT:
Explained above is the way I implemented it. Instead of a UiTextField and a button you can also use a UISearchBar and here's a nice link that can get you going.
How to search MKMapView with UISearchBar?