itc.opra
itc.opra

Reputation: 133

Geocoding API vs Geocoder

In my application I need to use the geocoding, but I am not quite clear which method to use. Until yesterday I added the parameters to the URL maps.googleapis.com/maps/api/geocode/json?address=myparameter&sensor=false, but Google blocked my requests for a day, making the application crash because it did not return any results from the request for geocoding.

Now I am using the Geocoder class that does the same thing and also I have seen that you can create and use an API key for Geocoding.
Which method do you recommend to use? What is the difference between the two methods, apart from the limitations of the requests?

Upvotes: 9

Views: 8231

Answers (4)

Myroslav
Myroslav

Reputation: 1237

Geocoder API is built into the system and it's easy to use. From my experience, it's working in most cases, although:

  • in some cases it fails and throws grpc failed IOException
       Non-fatal Exception: java.io.IOException: grpc failed
       at android.location.Geocoder.getFromLocation(Geocoder.java:136)
  • it may not be even available on some devices (use isPresent() method to verify this).

With above, I don't think Geocoder API is super reliable, so if geocoding is a critical part of your app, you may look into other options (like Google's Geocoding API, which is not free).

Upvotes: 3

Sachin Singh
Sachin Singh

Reputation: 169

Geocoder is a built-in API in the Android framework that is free. Geocoding API is a rest API that is paid. Geocoder uses a different search stack internally and this leads to different results comparing to the Geocoding rest API. The Geocoding rest API works better than Geocoder normally but has usage limits and the implementation is bigger.

Upvotes: 4

Andrea Montanari
Andrea Montanari

Reputation: 98

If you need to use a map in your app, you should use the API called: Google Maps Android API v2.

If you need to manage geocoded data (address to lat/lng or viceversa) then enable Geocoding API and start using the class Geocoder.

For example (lat/lng to address):

Geocoder geocoder = new Geocoder(this, Locale.getDefault());
addresses = geocoder.getFromLocation(gps.getLatitude(),  gps.getLongitude(), 1); 

Upvotes: 2

hammadmirza
hammadmirza

Reputation: 156

Users of free API have following limits:

  • 2,500 requests per 24 hour period.
  • 5 requests per second.

You can include API key in web-request also like:

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=API_KEY

Not sure about android Geocoder class, maybe someone else can help you out in that matter. But i assume same limits would apply.

Upvotes: 0

Related Questions