我想在我的应用中获取用户's current location from my iPhone app. I want to show the user'的当前位置,例如国家/地区名称,纬度,经度信息 . 而且我也希望在谷歌 Map 中显示位置 . 我也试过谷歌搜索,但无法得到确切的答案 . 我在我的应用程序中获取了使用 CLLocationManager
来跟踪位置的信息 . 我该如何使用它?我从Apple Documents下载了一个示例应用程序 . 这是链接:https://developer.apple.com/library/ios/#samplecode/LocateMe/Introduction/Intro.html
你能帮帮我吗?提前致谢 .
4 回答
1)我在我的应用程序中获取了使用
CLLocationManager
的信息来跟踪位置 . 我该如何使用它?在.h文件中
在.m文件中: -
2) . 我想在我的应用中显示用户的当前位置,例如国家/地区名称信息 .
为此您可以使用Google's Reverse Geo coding或MKReverseGeocoder
这应该做的大部分..
http://www.highoncoding.com/Articles/804_Introduction_to_MapKit_Framework_for_iPhone_Development.aspx
获取有关使用MKReverseGeocoder所需位置的信息
https://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKReverseGeocoder_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40008323
首先创建一个
MKMapView
的实例To get user's latitude and longitude :
在你的
viewDidLoad
And for country name 您将需要反向编码,您可以在这里查看类引用
https://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKReverseGeocoder_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40008323
OR
如果MKReverseGeoCoding太复杂,你可以使用雅虎的反向编码器
http://where.yahooapis.com/geocode?q=%f,%f&gflags=R&appid=yourAppId,那些2%f将是
userCoord.longitude
和userCoord.latitude
.是的,您可以使用CLGeoCoder . 但CLGeaCoder不会为印度等其他国家提供美国境外的累积地点信息 . 因此,最好使用谷歌的反向地理编码SVGeoCoder . SVGeoCoder具有很好的实现,可以通过goolePlaceAPI获取位置 .