查找当前位置的坐标并找出国家/地区

发布于 2024-11-28 15:18:46 字数 35 浏览 1 评论 0原文

是否可以找出我当前位置的坐标并找出它位于哪个国家/地区?

Is it possible to find out the coordinates of my current location and figure out which country this is in?

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

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

发布评论

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

评论(1

春风十里 2024-12-05 15:18:46

MKReverseGeocoder 类提供将地图坐标(指定为纬度/经度对)转换为有关该坐标的信息的服务,例如国家、城市或街道。

MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate];
reverseGeocoder.delegate = self;
[reverseGeocoder start];

然后你需要实现 MKReverseGeocoderDelegate 协议。这是获取您的信息后被调用的委托方法:

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
    // get the country string from placemark.country and use however you want.
}

The MKReverseGeocoder class provides services for converting a map coordinate (specified as a latitude/longitude pair) into information about that coordinate, such as the country, city, or street.

MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate];
reverseGeocoder.delegate = self;
[reverseGeocoder start];

Then you need to implement MKReverseGeocoderDelegate protocol. This is the delegate method that gets called once it gets your info:

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
    // get the country string from placemark.country and use however you want.
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文