I am trying to use CLGeocoder to reverse geocode an address and want to create an address dictionary programmatically to use to geocode with. How can I do that? I can't find anything on it! Thanks.
The docs in the CLGeocoder header file give you the info you need:
// geocodeAddressDictionary:completionHandler: takes an address dictionary as defined by the AddressBook framework.
// You can obtain an address dictionary from an ABPerson by retrieving the kABPersonAddressProperty property.
// Alternately, one can be constructed using the kABPersonAddress* keys defined in <AddressBook/ABPerson.h>.
- (void)geocodeAddressDictionary:(NSDictionary *)addressDictionary completionHandler:(CLGeocodeCompletionHandler)completionHandler;
Related
I looked at the API here, but it only mentions that you can get the GMSPlace for the user's current location. Is there any way to create my own custom GMSPlace object or get the GMSPlace for the lat/long I want? I looked at previous solutions but didn't find anything.
As per Google's docs:
Represents a particular physical place. A GMSPlace encapsulates
information about a physical location, including its name,
location, and any other information we might have about it. This
class is immutable.
Apparently there is no way to make your own GMSPlace object from the coordinates, nor there' a method that Google's SDK provide.
What I did before, I search for places, the one that Ajay user above discussed.
So the process is:
Get coordinates.
Reversegeocode to get the string address.
Search the string address using the GooglePlaces autocomplete.
From the first result in #3, the placeId is used to get the GMSPlace object using the lookUpPlaceID method.
Beware though that sometimes it returns a wrong address. I've tried it.
GMSPlace is a class provided by Places SDK which provides information about a specific place. You can not create your own custom object.
EDIT: To find a place other than your current location it provides Autocomplete api which automatically return location suggestions while users type.
I'm trying to have a user click an annotation and in the next view some information such as an address is represented in a UITextField. However when trying to get annotation.subtitle I get an error regarding the return value of MKAnnotation.subtitle to be String?? instead of what I want, String. Should I be using reverseGeocodeLocation ?
Yes, use it you will get a CLPlacemark Object, that contain, name, address...
Reference: https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLPlacemark_class/index.html#//apple_ref/swift/cl/c:objc(cs)CLPlacemark
I want to know how you convert geo coordinates into an address. I have already tried the CLGeocoder class but I have no idea how to convert my data.
Thanks
You need to use the CLGeocoder Class to get a coordinate to physical address lookup. The command you are looking for is reverseGeocodeLocation:completionHandler:. You pass your CLLocation location object containing the coordinate data to look up.
Read more about it in Apple's CLGeocoder Class Reference.
I am building an application that stores locations in a list and later maps them.
The problem I'm running into is an inability to save MKMapItems to a Parse database. I need to save these MKMapItems because they are the only unique identifiers for locations on a map that would not require searching the map again (ex.location name, ex. address).
So my question is, how can I save an MKMapItem to a Parse database?
And to follow up, if it is not possible to save an MKMapItem, how else can I save these items to a map so that I do not have to re-search?
MKMapItem: https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapItem_class/Reference/Reference.html
Parse:
https://www.parse.com/docs/ios_guide#top/iOS
EDIT
Another detail that might help: I'm using this to store information about particular venues. For example restaurants. I don't necessarily want to be creating a new map annotations at that mark if I can avoid it.
I'm not sure if Parse has prebuilt support for it, but you can definitely create your own class to do it:
1) You can create an MKMapItem from an MKPlacemark, using this init method
- (id)initWithPlacemark:(MKPlacemark *)placemark
2) MKPlacemark is basically just a coordindate and address, created using this init method
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary
CLLocationCoordinate2D can easily be stored in a custom class on Parse. If you care, you can also store the relevant address values too.
3) When you need to fetch MKMapItems, you actually fetch the underlying MKPlacemark coordinates, create MKPlacemarks, and finally create MKMapItems using each.
I have some geolocation data, and I need to parse it to CLLocationCoordinate2D from object geo
"geo": [
49.233083,
28.46821699999998]
I found some information on how this could work with RKCLLocationValueTransformer, but I don't understand how to get this to work for my situation.
You can't go direct to a CLLocationCoordinate2D because it's a struct, not a class.
RKCLLocationValueTransformer works in the same way as the value transformer for dates (which convert from NSString to NSDate instances) except that it converts from NSDictionary to CLLocation.
Your problem is that your JSON provides the location as an array, not a dictionary...
As such, you will need a different solution. You could look at making a modification to RKCLLocationValueTransformer (and raising a pull request). Your modification would add a different creation method (perhaps locationValueTransformerForArrayRepresentation:, which takes an enum parameter describing if the latitude or longitude comes first in the array). Then modify transformValue:toValue:ofClass:error: to check the configuration and make the appropriate mappings.
After you've done that the github page describes how to use the transformer.