Get Coordinates for given Location - objective-c

OK, here's what I want to implement and I need your ideas :
Input a geo location by name/address/etc (e.g. London, Oxford Street 20)
Get the point's longitude/latitude
My Questions :
How would you go about that?
Is using Google Maps API (that's what I first thought of) my only solution?
It'd be better if the service used CAN be freely integrated in a commercial app - so any idea is welcome... :-)

What you are trying to do is basically geocoding. Major map providers like Google, Bing and Yahoo (and many more) all offer some form of Geocoding API for you to take advantage of. Check out the following quick links:
Google Maps Geocoding API
Bing Locations API
Yahoo! Maps Web Services (Geocoding API)
Edit: (just saw the objective-c tag)
Note that these are non-native solutions. However, the provided APIs are typically REST-based (with output as xml/json), it shouldn't be hard for you to consume these services to grab the gecoded lat-long that you want from within your app.

There is a built in API for that.
For iOS 5 and newer you can use CLGeocoder and for older version you will need to use some extern libraries.
Just call
- (void)geocodeAddressString:(NSString *)addressString completionHandler:(CLGeocodeCompletionHandler)completionHandler
where you want to get the location. It runs async and in the completionHandler you will get an array of all possible placemarks for your address where the first one is the most accurate. As apple says:
For most geocoding requests, this array should contain only one
entry. However, forward-geocoding requests may return multiple
placemark objects in situations where the specified address could not
be resolved to a single location.
Off topic:
Am I the only one whos first thoughts about Oxford was "What does he mean with this weird Hex value?"

Related

Get address by location

I'm using Bing Maps on Windows store app (XAML).
I have the longitude and the latitude and I want to get the address (if it exists) of the location.
How can I do it?
Thanks!
You want to do what is called reverse geocoding. Take a look at the SearchManager class: http://msdn.microsoft.com/en-us/library/dn306041.aspx This will let you reverse geocode your coordinates and get the address.
Alternatively you can also use the Bing Maps REST services:
This would be more work than using the search manager, but wouldn't require loading an interactive map first.
http://msdn.microsoft.com/en-us/library/ff701710.aspx
http://msdn.microsoft.com/en-us/library/jj819168.aspx
http://msdn.microsoft.com/en-us/library/jj870778.aspx
Since it sounds like you are new to using Bing Maps in Windows Store apps I'd recommend downloading a free copy of my eBook on creating location intelligent Windows Store apps. It shows how to do this an a lot more. You can get a copy of it here: http://rbrundritt.wordpress.com/my-book/

The Geocoding api returns a wrong location for a pincode, but Google maps returns right location

I used the pincode (400036) in the geocoding webservice, but got a location in China. The webservice is shared below.
http://maps.google.com/maps/api/geocode/json?address=india&components=postal_code:400036&sensor=false
Ideally it should be a location in Mumbai (Bombay) in the state of Maharashtra, India.
Any ideas why this could occur?
Also, any other parameters that can be passed to make this particular pin code work?
Thanks and regards,
Anand
P.S.: I'm a Business Analyst, so my technical know-how and command of programming languages is pretty limited. However, I'll be most happy to receive help from the community here and pass it on to my dev team. Thanks.
Geocoding and working with real-world data is hard, and not even the great Google (no sarcasm, I'm a fan) gets it right all the time. Apparently there is a software or data bug in the Google API, since this works (added Country India to the component filter):
http://maps.google.com/maps/api/geocode/json?components=postal_code:400001%7Ccountry:IN&sensor=false
But this does not, and is not even filtering by country because it still returns Chinese results:
http://maps.google.com/maps/api/geocode/json?components=postal_code:400036%7Ccountry:IN&sensor=false
If you're a paying customer, you can contact Google for support here: http://www.google.com/enterprise/portal
You can use http://geoanalyzer.in for this. Google maps and google api are slighly different as Google Maps shows you results from both Google Maps API and also from Google places hence a lot of time you get wrong data in case of Google Maps API. Geo Analyzer solved this and has been built specifically for Indian addresses.
This is one of the few available solutions that is targeted for Indian address system complexity. I hope this will help.

Database Postcode Records, Google Maps?

Currently I have a website and database solution, however I would like to take 'Postcodes' from the records and place corresponding markers for them on a Google maps view.
Is this possible? And where would I start? Thanks
You can use the Google Maps Javascript API to place a map on your webpage. There is a good code example section. Markers should be easy to find.
The process of translating a postcode to a map location is called geocoding. There are code samples here too. The geocoding API has a usage limit and it takes time to do its work. SO if you have many postcodes, you might want to cache geocoding results.
There are many, many ways to get postcodes from a database to JavaScript. If you have an issue there, you'd better ask a more specific question, including the platform and language tag.

Reverse geocode without using MKReverseGeocoder

I'm trying to detect current user address using MKReverseGeocoder passing coordinates obtained via CLLocation class. Reading MKReverseGeocoder Class Reference I noticed that
The Google terms of service require that the reverse geocoding service be used in conjunction with a Google map; take this into account when designing your application's user interface.
so I'm wondering if (and eventually how) can I reverse geocode user current location on iPhone OS SDK 3.1.3.
I thought using Google Maps API but the EULA has the same obligation.
Yahoo Maps API is even worse and Microsoft one aren't free.
http://www.geonames.org/ is another free alternative
Well if the EULA of Google has the obligation and you are not following it ( similar topic here), then of course you can't do it.
Still I would advice you to find some alternatives, what about this, it's free and doesn't look bad at all.
a question on geonames:
for retrieving city i must pass north,south,eas,west; there's a way to pass only lat & long for retrieve city? I canno't find method to do...

Address validation using Google Maps API

I have a task to validate addresses entered into a system I am currently creating. The system requires that address entered are validated against a valid data source. In the UK the dataset comes from the Royal Mail and is expensive to access.
The data needed is post code info for the whole of europe to start with accessed by an API into the web application.
There are a number of companies that offer this service,
QAS
Capscan
Postcode anywhere
These all offer the service I require. However this is expensive and in some cases not a complete data set. e.g. not Ireland
I was also wondering if there would be a way to utilize the Google Maps API to validate this data via postal code and country.
Would the google maps method be possible or do I have to go down the line of one of these expensive companies? Any thoughts on what line I should take.
The answer probably depends how critical it is for you to receive support and possible customization for this service.
Google can certainly do this. Look into their XML and Geocoding API's. You should be able to craft an XML message asking Google to return Map coordinates for a given address. If the address is not found (invalid), you will receive an appropriate response. Here's a useful page: http://code.google.com/apis/maps/documentation/services.html#XML_Requests
Note that Google's aim in providing the Maps API is to plot addresses on actual maps. While you can certainly use the data for other purposes, you are at the mercy of Google should one of their maps not exactly correspond to your legal or commercial address validation needs. If you paid for one of the services you mentioned, you would likely be able to receive support should certain addresses not resolve the way you expect them to.
In other words, you get what you pay for ;) . If you have the time, though, why not try implementing a Google-based solution then going from there? The API looks pretty slick, and it's free, after all.
Google's geocoding api does what want you want. As Xerus points out, as long as you are not using the geocoded points on a non-google Map, you should be good (terms of service). Specifically,
3.1 Use without a Google Map. Customer may use Google Maps Content from the Geocoding API in Customer Applications without a corresponding Google Map.
3.3 No use with a non-Google map. Customer must not use Google Maps Content from the Geocoding API in conjunction with a non-Google map.
I am both a web developer and a former employee of one of the companies you mentioned. I completely understand where you're coming from. Verifying addresses seems like a simple problem to tackle, but it's very much an iceberg. I suppose one workaround to the legal constraints of the Google or Yahoo! Maps APIs is to request your users verify their addresses on a map. If I were in your shoes, though, I wouldn't go that route.
The reason address verification services are so expensive is that they require licenses and ongoing relationships with grumpy, bureaucratic postal authorities (including the Royal Mail). Unfortunately, postal authorities are the best (and often the only) sources of data against which to verify addresses, so there really isn't any other way to go about it. The bottom line is you need to weigh the cost of bad addresses (usually a question of mail volume) against the cost of the software to verify them. Irish postal data is even more rubbish than Irish postal formats (which frequently omit building numbers), so there's little you can do about those addresses.
The answer depends upon the degree of confidence you place in the data and how your data is being used. For example, if you're using it for mailing or shipping, you'll want to be be confident that the data is correct. If you're just using it as another fraud-prevention mechanism then you could potentially allow a degree of error to creep into the data.
If you want any degree of real accuracy, you're need to go with a service that does real address verification and you're going to have to pay for it. As has been mentioned by Adam, address verification and validation at first seems simple and easy, but it's a black hole fraught with challenges and, unless you've some underlying data to work with, virtually impossible to do by yourself. Trust me, you're actually saving money by using a service. You're welcome to go down this road yourself to experience what I mean, but I can guarantee you'll see the light, so to speak, after even a few hours (or days) of spinning your wheels.
I should mention that I'm the founder of SmartyStreets. We do address validation and verification addresses and we offer this for the USA and international as well. I'm more than happy to personally answer any questions you have on the topic of address cleansing, standardization, and validation.
Another option is YADDRESS.
Validate it against FedEx's api. They have an API to generate labels from XML code. The process involves a step to validate the address.
Google basis (free) does not provide address verification (Geocoding) as there is no UK postcode license.
This means postcode searches are very in-accurate. The proximity search is very poor, even for town searches, often not recognising locations.
This is why Google have a premier and a enterprise solution which still is more expensive and not as good as business mapping specialists like bIng and Via Michelin who also have API's.
As a free lance developer, so serious business would use Google as the system is weak and really provides a watered down solution.
I know that this post is a bit old but incase anyone finds it still relevant you might want to check out the free geocoding services offered by USC College. This does included address validation via ajax and static calls. The only catch is that they request a link back and only offer allotments of 2500 calls. More than fair.
https://webgis.usc.edu/Services/AddressValidation/Default.aspx
You could consider using CDYNE's PAV-I API that validates international addresses. international-address-verification They cover over 240 countries, so it should cover all of the countries that you are looking to validate for.
A great blog describing 14 address finders:
https://www.conversion-uplift.co.uk/free-address-lookup-tools/
Many address autocomplete services, including Google's Places API, appears to offer international address support but it has limited accuracy.
For example, New Zealand address and geolocation data are free to download from Land Information New Zealand (LINZ). When a user search for an address such as 76 Francis St Hauraki from Google or Address Doctor, a positive match is returned. The land parcel was matched but not the postal/delivery address, which is either 76A or 76B. The problem is amplified with apartments and units on a single land parcel.
For 100% accuracy, use a country-specific address finder instead such as https://www.addy.co.nz for NZ address autocomplete.