How to implement the Google Distance Matrix API in Java without using the HTTP request method

1.4k views Asked by At

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.

1

There are 1 answers

1
Anass Omar On

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