-1

I am aware of the fact that I am able to use a HTTP request to use the distance matrix API (i.e. https://maps.googleapis.com/maps/api/distancematrix/json?origins=42.11622,78.10112&destinations=40.82231,72.224166&key=YOUR_API_KEY)

But I would like to simply use the Java API instead. From my understanding the first step is to create a GeoApiContext and this seems to be where I am failing. I have tried the following code:

private static GeoApiContext context = new GeoApiContext.Builder().apiKey("MyKey").queryRateLimit(500).build();

However I am just met with the following compile error:

java.land.NoClassDefFoundError: com/google/common/util/concurrent/RateLimiter

Any help on the matter would be appreciated. The plan is to use this to create a DistanceMatrix API request if that helps.

H Wood
  • 1
  • 1
  • It might also be useful to know that I am using version 0.2.2 of the Java API – H Wood Aug 30 '17 at 11:41
  • It looks like [RateLimiter](https://google.github.io/guava/releases/19.0/api/docs/index.html?com/google/common/util/concurrent/RateLimiter.html) belongs to the [Guava: Google Core Libraries for Java](https://github.com/google/guava). Did you include the guava in your project dependencies? – xomena Sep 01 '17 at 14:14
  • Checkout this answer -[Finding distance and time between two places using google distance matrix api](https://stackoverflow.com/a/48487598/7849549) – Shubham Dixit Jan 28 '18 at 14:51

1 Answers1

0

check out this link you may find it useful... there are code examples https://www.programcreek.com/java-api-examples/index.php?api=com.google.maps.model.DistanceMatrix

Anass Omar
  • 11
  • 1
  • 4
  • Thanks, this seems useful to have for after the geoApiContext has been setup, which is unfortunately the thing I am trying to first sort :( – H Wood Sep 05 '17 at 14:35