Forward geocoding from the iPhone

流过昼夜 提交于 2019-11-26 08:06:52

问题


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.


回答1:


iOS 5 now allows for forward Geocoding:

http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/UsingGeocoders/UsingGeocoders.html#//apple_ref/doc/uid/TP40009497-CH4-SW5

I hope this helps!




回答2:


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/




回答3:


I have created SVGeocoder, a simple forward and reverse geocoder class for iOS. It uses the Google Geocoding API as well and returns an 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 coordinate = CLLocationCoordinate2DMake(45.54181, -73.62928);
SVGeocoder *rGeocoderRequest = [[SVGeocoder alloc] initWithCoordinate:coordinate];
[rGeocoderRequest setDelegate:self];
[rGeocoderRequest startAsynchronous];

The SVGeocoderDelegate offers these 2 methods:

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



回答4:


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




回答5:


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

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




回答6:


There is also a framework here: 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.




回答7:


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.



来源:https://stackoverflow.com/questions/1140404/forward-geocoding-from-the-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!