为 iPhone 开发者提供的最佳地理编码服务
我制作了一个应用程序,可以从网络服务获取一系列地址,并且我想映射它们。我知道苹果在 MapKit 中遗漏了这一点,只包括反向地理编码器。我想知道解决这个问题的最佳方法是什么。网络服务? Google 地图 API(API 密钥如何工作?)?云制造?
您对哪种服务最快、最容易使用且最便宜(希望免费)有何看法?
I have made an app that gets an array of addresses from a web service and I want to map them. I know Apple left this out in MapKit, including only a reverse Geocoder. I was wondering what the best way to approach this problem was. Web Service? Google Maps API (How do API keys work?)? CloudMade?
What is your opinions on which service is fastest, easiest to use, and cheapest (hopefully free)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
有关 Google 地图地理编码服务 API 中 API 密钥的使用的最新文档。
获取 API Key
可以参考底部您可以使用通用的无限制 API 密钥在任何平台上进行测试的页面。
至于iOS,我认为我们可以按照iOS的Google Maps SDK文档进行操作。
Latest documentation regarding the usage of API keys with Google Maps Geocoding service API.
Get API Key
It can be referred to at the bottom of the page that you can use a generic unrestricted API key for testing in any platform.
As for iOS, I think we can just follow the Google Maps SDK documentation for iOS.
IANAL,但如果您正在构建的应用程序是免费的,那么我相信您可以免费使用 Google Maps API。每天的地理编码请求限制为 15,000 个,但根据文档,这与 IP 绑定,而不是 API 密钥。您可以立即获取 API 密钥 - 无需批准。 (如果您的应用程序不是免费提供的,那么您必须注册 Google Maps Premier。)
GMaps 现在有一个基于 REST 的 基于 HTTP 的地理编码 API(过去您必须使用他们的 JavaScript API,这在 iPhone 上很痛苦)。它可以以 JSON 形式返回,如果您需要,使用 TouchJSON 解析该数据很简单额外数据或 CSV,如果您只需要纬度/经度,这会更容易。因此,您可以创建一个符合 MKAnnotation 协议 将使用 NSURLConnection 或 ASIHTTPRequest 从 API 获取 JSON/CSV,对其进行解析,然后返回
Point
变量作为cooperative
属性,根据需要构建您的 MapView。IANAL, but if the app you're building will be free, then I believe you can use the Google Maps API for free. It's limited to 15,000 geocoding requests per day, but according to the docs, that's tied to IP, not API key. You can get an API key immediately — no approval required. (If your app will not be freely available then you will have to sign up for Google Maps Premier.)
GMaps now has a REST-based geocoding API over HTTP (it used to be you had to use their JavaScript API, which was a pain on iPhone). It can return in JSON, which is trivial to parse using TouchJSON if you need the extra data, or CSV, which will be even easier if all you need is lat/lon. So, you can just create an object that conforms to the MKAnnotation protocol that will fetch the JSON/CSV from the API using an NSURLConnection or ASIHTTPRequest, parse it, and return the
Point
variable as thecoordinate
property and build your MapView as required.为此使用 Apple Geocoding API
http:// developer.apple.com/library/ios/#documentation/userexperience/conceptual/LocationAwarenessPG/UsingGeocoders/UsingGeocoders.html
“CLGeocoder 类提供在坐标(指定为纬度和经度)和用户之间进行转换的服务- 该坐标的用户友好表示通常由与给定位置相对应的街道、城市、州和国家信息组成,但它也可能包含相关的兴趣点、地标或其他标识。地理编码器对象是一个单次对象,它与基于网络的服务一起查找其指定坐标值的地标信息。
要使用地理编码器对象,请创建它并调用其正向或反向地理编码方法之一 。开始请求。反向地理编码请求采用纬度和经度值并查找用户可读的地址。正向地理编码请求采用用户可读的地址并查找相应的纬度和经度值。正向地理编码请求还可以返回有关指定位置的附加信息,例如该位置处的兴趣点或建筑物。对于这两种类型的请求,结果均使用 CLPlacemark 对象返回。在前向地理编码请求的情况下,如果提供的信息产生多个可能的位置,则可能会返回多个地标对象。”
Use Apple Geocoding API for this
http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/LocationAwarenessPG/UsingGeocoders/UsingGeocoders.html
"The CLGeocoder class provides services for converting between a coordinate (specified as a latitude and longitude) and the user-friendly representation of that coordinate. A user-friendly representation of the coordinate typically consists of the street, city, state, and country information corresponding to the given location, but it may also contain a relevant point of interest, landmarks, or other identifying information. A geocoder object is a single-shot object that works with a network-based service to look up placemark information for its specified coordinate value.
To use a geocoder object, create it and call one of its forward- or reverse-geocoding methods to begin the request. Reverse-geocoding requests take a latitude and longitude value and find a user-readable address. Forward-geocoding requests take a user-readable address and find the corresponding latitude and longitude value. Forward-geocoding requests may also return additional information about the specified location, such as a point of interest or building at that location. For both types of request, the results are returned using a CLPlacemark object. In the case of forward-geocoding requests, multiple placemark objects may be returned if the provided information yielded multiple possible locations."
我使用“Restful WebService”使用 Google 地图进行反向地理编码,一旦获得坐标,我将它们存储在 SQLite 中以供以后参考。该服务返回一个 JSON 字符串,我稍后在 iPhone 中解析该字符串。
像这样的东西:
I use a "Restful WebService" for Reverse Geocoding using Google Maps and once I get the coordinates I store them in SQLite for later reference. The service returns a JSON string which I later parse in the iPhone.
Something like:
根据谷歌和雅虎的说法,他们各自的地理编码服务不允许“存储以供将来使用”。除非我误解了,否则您不能将查询结果存储到任何形式的数据库中。否则,只用 Google 就很容易了(现在每天有 50,000 个请求)。
According to both Google and Yahoo, their respective geocoding services DO NOT allow for "storage for future use." Unless I've misunderstood, you cannot store query results into any form of database. Otherwise it'd be really easy to just Google (now 50,000 requests per day).