I have a problem with CLGeocoder where when I call geocodeAddressString:withCompletionHandler I only ever get one result back, despite knowing that the inputted string should return more than one value. The class reference even states:
In the case of forward-geocoding requests, multiple placemark objects may be returned if the provided information yielded multiple possible locations.
However, my placemarks array only ever has one item in it:
[geocoderDestination geocodeAddressString:destination completionHandler:^(NSArray *placemarks, NSError *error){
NSLog(#"array count:%i", [placemarks count];}
Thank you for any help.
I have used strings such as "Piccadilly, UK", "Union Street, UK" which have only returned one result. Now that I think about it, putting UK on the end might be the contributing factor.
I dont know about CLGeocoder but if your requirement is a location search another way is to use google location search url http://maps.google.com/maps/geo?q=london which returns a json containing the matched location information.
Instead of UK use United Kingdom it will give you some related result.
Try to add some more info in your address.
One more thing UK is not a valid country code it's GB but it seems that putting GB instead of UK didn't solve the problem.
Moreover CLGeocoder is not as smart as Google Maps API right now because apple uses its own server to decode addresses so you can use Google services.
Related
Is it possible to get coordinates to be used in Google Maps/Apple Maps (depending on iOS versiĆ³n) based on a given direction? I've got the directoon (street and number), the post code and the country (in my case, the country will always be Spain)
Thank you
You need to use Geocoder for that, find a guide here:
Geocoding Location Data
You can find an example at the end of the document:
[geocoder geocodeAddressString:#"1 Infinite Loop"
completionHandler:^(NSArray* placemarks, NSError* error){
for (CLPlacemark* aPlacemark in placemarks)
{
// Process the placemark.
}
}];
As they say, the more info you provide, the more accurate will be.
I want to develop my own maps app. I have been successful in getting a street address at the point of touch on my iPhone using CLGeocoder. Now my question is the following:
I know that you can get information about a place by using a URL like https://maps.google.com/?q=37.324599,-122.031844
If you click on the above URL, it will take you near a church in Cupertino. Now CLGeocoder will only give me its street address i.e. 10110 N De Anza Blvd Cupertino, CA 95014 (I get this). But how to get the actual name i.e. St Joseph of Cupertino Church and Parish?
We can see it on Google Maps that means they must have it stored somewhere right?
Is there any way to access those place names (Not just by CLGeoCoder, any way is fine).
The GeoCoding API in general is for converting between street addresses and coordinates. If you want place names you can probably use the Places API.
(I know this is more of a comment than an answer, but I think I don't have enough reputation points to comment on questions yet)
YOu need t odo like this way after getting lat long use this code by CLLocation manager class
{
CLGeocoder *reverseGeo = [[CLGeocoder alloc] init];
[reverseGeo reverseGeocodeLocation: loc completionHandler:
^(NSArray *placemarks, NSError *error) {
NSLog(#"%#",[placemarks objectAtIndex:0]);
for (CLPlacemark *placemark in placemarks) {
NSLog(#"~~~~~~~~%#",placemark.locality);
}
}];
}
I am attempting to modify our app from using MKReverseGeocoder to CLGeocoder for devices running iOS 5, but I'm getting different results from the two classes. Specifically, when doing a reverse geocode with this coordinate:
(47.643126, -122.204037)
I get this from MKReverseGeocoder:
10210 NE Points Dr
Kirkland, Washington 98033
but I get this from CLGeocoder:
9601-10267 NE Points Dr
Kirkland, Washington 98033
The second value is much less specific than the first and therefore much less useful. The solution for now is to just use MKReverseGeocoder, but at some point we'll be forced to switch.
Q: Any idea how to improve the results from CLGeocoder?
Thanks,
David
update their database. In short their data is less specific/accurate so there is nothing you can do apart from accept their less accurate data
Is there a way to find out the users location Continent? I need to set an AWS entry point based on if they open the app in the US, or Europe. etc.
Is there a way to do this without taking GPS coordinates and making ranges out of them?
If you are in iOS5, you can use GLGeocoder to retrieve the information abotu a current location:
[self.CLGeocoder reverseGeocodeLocation: locationManager.location completionHandler:
^(NSArray *placemarks, NSError *error) {
CLPlacemark *placemark = [placemarks objectAtIndex:0];
//placemark contains the address
}];
CLPlacemark reference:
https://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLPlacemark_class/Reference/Reference.html
GLGeocoder reference:
https://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLGeocoder_class/Reference/Reference.html
you can reverse geocode a location and get details of where the user is located in text. You use the reverseGeocodeLocation:completionHandler: method on the CLGeocoder class to do this
The completion handler in this method gets passed in an array of CLPlacemark objects, which contain the country code, which you can use to determine the users continent
Although a CLPlacemark object contains lots of useful information, its corresponding continent is not present on it.
I wrote a small category to add a -continent method that returns the corresponding string of the continent based on the -ISOCountryCode of a CLPlacemark.
https://github.com/Hecktorzr/Transcontinental
Anyone know how to get thew Google Maps API HTTP request/response to only return me Locations that fall within Australia ?
I thought I could just add:
bounds=lat, long | lat Long
Creating a square boundary based off Coordinates, but Google for some strange reason isn't liking it.
[NSString stringWithFormat:#"%#%#+Australia&bounds=-9.102097,104.765625|-44.902578,159.697266&sensor=false®ion=au", kGoogleGeocodeURL, params];
Problem resolved, it turns out that the search string was correct, but I needed to use UTF8Encoding, as NSString didn't like the Commas.