Search code examples
androidgoogle-mapsgoogle-geocoder

Google-GeoCoder or Google-DistanceMatrix ....... which is better to use ? and why?


I am new to Android & I am learning how to use Geocoder

What i have done::

  • I did some R&D in Internet, My observation is GeoCoder uses MAP-API
  • it has some functions to give the information details of the place like Place, streetName etc
  • I came across something called Google distance matrix
  • Using that also we can fetch the information regarding place but looks like it has only 1500 req/day free else more we have to pay

My Questions::

  • Can GeoCoder fetch me location details if i don't use MAP-API in my mobile ?
  • Can geocoder fetch location information directly from internet ?
  • Which one is better to use Distance matrix or Geocoder ? ... if either one .... why ?

Solution

  • Which one is better to use Distance matrix or Geocoder ?

    The Geocoder and the Distance Matrix API are for different use cases.

    With the android.location.Geocoder you will get the coordinates for a specific street name f.e. If you provide the city/street name/administrative areas etc. it will responde a pair of latitude and longitude. This is also possible for the other way around called reverse geocoding. If you provide the latitude and longitude it will responde the fitting street name.

    The Distance Matrix API will responde the duration and the distance to reach a destination from an origin. To be exact, this API will take multiple origins and destinations and computes the distance and duraton for them.

    Can GeoCoder fetch me location details if i don't use MAP-API in my mobile ?

    The Geocoder is part of the android.location package, hence you don't need the com.google.android.gms.maps library.

    Can geocoder fetch location information directly from internet ?

    Yes, but you have to use the Geocoding API. The Geocoder from the SDK is communicating directly with Google Services.