Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Java中实现Google距离矩阵API而不使用HTTP请求方法_Java_Google Maps_Google Api Java Client_Google Distancematrix Api - Fatal编程技术网

如何在Java中实现Google距离矩阵API而不使用HTTP请求方法

如何在Java中实现Google距离矩阵API而不使用HTTP请求方法,java,google-maps,google-api-java-client,google-distancematrix-api,Java,Google Maps,Google Api Java Client,Google Distancematrix Api,我知道我可以使用HTTP请求来使用距离矩阵API(即https://maps.googleapis.com/maps/api/distancematrix/json?origins=42.11622,78.10112&destinations=40.82231,72.224166&key=YOUR_API_key) 但是我想简单地使用JavaAPI。根据我的理解,第一步是创建GeoApiContext,这似乎是我失败的地方。我尝试了以下代码: private static GeoApiConte

我知道我可以使用HTTP请求来使用距离矩阵API(即
https://maps.googleapis.com/maps/api/distancematrix/json?origins=42.11622,78.10112&destinations=40.82231,72.224166&key=YOUR_API_key

但是我想简单地使用JavaAPI。根据我的理解,第一步是创建GeoApiContext,这似乎是我失败的地方。我尝试了以下代码:

private static GeoApiContext context=new GeoApiContext.Builder().apiKey(“MyKey”).queryRateLimit(500.build()

但是,我刚刚遇到以下编译错误:

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


在此问题上如有任何帮助,将不胜感激。如果有帮助的话,我们计划使用它来创建一个DistanceMatrix API请求。

查看此链接,您可能会发现它很有用。。。这里有一些代码示例

知道我使用的是Java API的0.2.2版可能也很有用,因为它看起来属于。您是否将番石榴包含在项目依赖项中?请查看此答案-谢谢,在设置geoApiContext之后,这似乎很有用,不幸的是,这是我尝试首先排序的内容:(