将地址转换为经度和纬度 [英] Convert address to longitude and latitude

查看:153
本文介绍了将地址转换为经度和纬度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行以下
- 允许用户在ios应用中输入物理地址。
- 此地址转换为经度/纬度
- Django服务器代码检查以查看附近的位置。

I want to do the following - Allow users to input a physical address in ios app. - This address is converted to longitude/latitude - Django server code checks to see nearby locations.

如何最有效地执行此操作?

How can I do this most efficiently?

我应该将地址转换为ios app中的经度和纬度,然后将坐标发送到django服务器代码,或者我应该将地址发送到django服务器代码然后隐蔽地址到经度和纬度?

Should I convert the address to longitude and latitude in ios app and then send the coordinates to django server code, or should I send the address to django server code and then covert address to longitude and latitude?

任何帮助都将不胜感激!

any help would be appreciated!

推荐答案

根据Apple的位置感知编程指南您可以使用CLGeocoder对象实现此目的:

According to the Apple's Location Awareness Programming Guide You can achieve this using a CLGeocoder object:

CLGeocoder* geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:@"Your Address"
     completionHandler:^(NSArray* placemarks, NSError* error){
         for (CLPlacemark* aPlacemark in placemarks)
         {
         // Process the placemark.
         }
}];

CLPlacemark对象有一个名为location的属性,可以为该地点产生纬度和经度。

A CLPlacemark object has a property called location that yields latitude and longitude for the place.

这篇关于将地址转换为经度和纬度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆