如何获取用户';iphone应用程序中的当前位置(按代码)?

如何获取用户';iphone应用程序中的当前位置(按代码)?,iphone,ios,google-maps,location,currentlocation,Iphone,Ios,Google Maps,Location,Currentlocation,我想从我的iPhone应用程序中获取用户的当前位置。我想在我的应用程序中显示用户的当前位置,如国家名称、纬度、经度信息。我还想在谷歌地图上显示位置。我也尝试过谷歌搜索,但没有得到确切的答案。我已经获得了在我的应用程序中使用CLLocationManager跟踪位置的信息。我怎么用这个?我从Apple Documents下载了一个示例应用程序。以下是链接: 你能帮我一下吗?提前谢谢 这应该可以解决大部分问题 要获取有关位置的信息,需要使用MKReverseGeocoder 1)我已经获得了在我的

我想从我的iPhone应用程序中获取用户的当前位置。我想在我的应用程序中显示用户的当前位置,如国家名称、纬度、经度信息。我还想在谷歌地图上显示位置。我也尝试过谷歌搜索,但没有得到确切的答案。我已经获得了在我的应用程序中使用
CLLocationManager
跟踪位置的信息。我怎么用这个?我从Apple Documents下载了一个示例应用程序。以下是链接:


你能帮我一下吗?提前谢谢

这应该可以解决大部分问题

要获取有关位置的信息,需要使用MKReverseGeocoder

1)我已经获得了在我的应用程序中使用
CLLocationManager
跟踪位置的信息。我怎么用这个

在.h文件中

#include <CoreLocation/CLLocationManagerDelegate.h>
#include <CoreLocation/CLError.h>
#include <CoreLocation/CLLocation.h>
#include <CoreLocation/CLLocationManager.h>

CLLocationManager   * myLocationManager;

CLLocation          * myLocation;
2) 。我想在我的应用程序中显示用户的当前位置,如国家名称信息


为此,您可以使用或首先创建
MKMapView

获取用户的纬度和经度

视图中加载

[yourMapView setShowsUserLocation:YES];

CLLocationCoordinate2D userCoord;

userCoord.latitude=map_view.userLocation.coordinate.latitude;
userCoord.longitude=map_view.userLocation.coordinate.longitude;

//NSLogging these on simulator will give you Cupertino or whatever location you set in location simulation.
对于国家名称您需要反向编码,您可以在此处查看类参考

如果mkreversegeocode变得太复杂,你可以使用雅虎的reversegeocoder


,这2%f将是
userCoord.longitude
userCoord.latitude

是的,您可以使用CLGeoCoder。但CLGeaCoder不会为印度等其他国家提供美国以外的地理位置信息,所以最好使用谷歌的反向地理编码。SVGeoCoder有很好的实现,可以通过GoolePeacei获取位置。

请注意,MKReverseGeocoder已不存在。您必须使用CLGeocoder并使用reverseGeocode功能,可能重复
[yourMapView setShowsUserLocation:YES];

CLLocationCoordinate2D userCoord;

userCoord.latitude=map_view.userLocation.coordinate.latitude;
userCoord.longitude=map_view.userLocation.coordinate.longitude;

//NSLogging these on simulator will give you Cupertino or whatever location you set in location simulation.