ios 从 iPhone 转发地理编码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1140404/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 16:11:27  来源:igfitidea点击:

Forward geocoding from the iPhone

iphoneiosgeolocationgeocoding

提问by samvermette

Given that the mapkit doesn't provide forward geocoding functionality today, can anyone provide help on how I can i use a search bar to return a latitude and longitude coordinate from a user inputted address today. If someone can provide sample code that would be great.

鉴于今天的 mapkit 不提供正向地理编码功能,任何人都可以提供有关我如何使用搜索栏从今天用户输入的地址返回纬度和经度坐标的帮助。如果有人可以提供示例代码,那就太好了。

回答by Merrimack

I've created a forward geocoding API for Google's geocoding server. Check out my blogpost: http://blog.sallarp.com/ipad-iphone-forward-geocoding-api-google/

我为 Google 的地理编码服务器创建了一个正向地理编码 API。查看我的博文:http: //blog.sallarp.com/ipad-iphone-forward-geocoding-api-google/

回答by samvermette

I have created SVGeocoder, a simple forward andreverse geocoder class for iOS. It uses the Google Geocoding API as well and returns an MKPlacemark.

我已经创建了SVGeocoder,这是一个用于 iOS的简单正向反向地理编码器类。它也使用 Google Geocoding API 并返回一个MKPlacemark

This is how you geocode an address string:

这是对地址字符串进行地理编码的方式:

NSString *addressString = @"3245 St-Denis, Montreal"
SVGeocoder *geocodeRequest = [[SVGeocoder alloc] initWithAddress:addressString];
[geocodeRequest setDelegate:self];
[geocodeRequest startAsynchronous];

And you reverse geocode an CLLocationCoordinate2D object like this:

然后像这样对 CLLocationCoordinate2D 对象进行反向地理编码:

CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(45.54181, -73.62928);
SVGeocoder *rGeocoderRequest = [[SVGeocoder alloc] initWithCoordinate:coordinate];
[rGeocoderRequest setDelegate:self];
[rGeocoderRequest startAsynchronous];

The SVGeocoderDelegate offers these 2 methods:

SVGeocoderDelegate 提供了这两种方法:

- (void)geocoder:(SVGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark;
- (void)geocoder:(SVGeocoder *)geocoder didFailWithError:(NSError *)error;

回答by mangesh

I have done some small work on forward and reverse geocoding using CLGeocoder in iOS5 CoreLocation framework on github hope it help you. https://github.com/Mangesh20/geocoding

我在 github 上的 iOS5 CoreLocation 框架中使用 CLGeocoder 做了一些关于正向和反向地理编码的小工作,希望对你有所帮助。 https://github.com/Mangesh20/geocoding

回答by Ramin

It's a known issue with the current version of MapKit. File a bugreport and dupe #6628720 so they make fixing it a priority.

这是当前版本的 MapKit 的一个已知问题。提交错误报告并欺骗 #6628720,因此他们将修复它作为优先事项。

In the meantime, there are forward Geocoding APIs from Google Maps, via Yahoo Placemaker, or Cloudmade.

与此同时,还有来自Google MapsYahoo PlacemakerCloudmade 的转发地理编码 API 。

回答by RefuX

There is also a framework here: https://github.com/tylerhall/CoreGeoLocation

这里还有一个框架:https: //github.com/tylerhall/CoreGeoLocation

Comment from docs: An Objective GeoCoder and Reverse Geocoder wrapping around Yahoo's Geocoding services or Google's Geo APIs primarily.

来自文档的评论: 主要围绕雅虎地理编码服务或谷歌地理 API 的目标地理编码器和反向地理编码器。

回答by Stefan Arentz

There is no such functionality in MapKit. The best you can do is to call a third party web service. Google has some APIs to do this and so had Yahoo I think. Both have restrictions on commercial use though, so read the agreement.

MapKit 中没有这样的功能。您能做的最好的事情是调用第三方 Web 服务。谷歌有一些 API 可以做到这一点,我认为雅虎也有。两者都对商业用途有限制,所以请阅读协议。