我想获取客户从Google Places API输入的位置名称的纬度和经度。执行冻结在第二行。
try {
GeoApiContext context = new GeoApiContext.Builder().apiKey("MY_API_KEY").build();
PlaceDetails placeDetails = PlacesApi.placeDetails(context, "Nairobi").await();
double lat = placeDetails.geometry.location.lat;
double lng = placeDetails.geometry.location.lng;
} catch (ApiException | InterruptedException | IOException apiException) {
apiException.printStackTrace(System.out);
}
我得到了以下堆栈跟踪,但我无法确定根本原因,因为我运行的示例在提供的测试中是最简单的。
我的应用程序中包含的库是:
这是堆栈跟踪I门和
Info: apartments was successfully deployed in 2,737 milliseconds.
Severe: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
Severe: SLF4J: Defaulting to no-operation (NOP) logger implementation
Severe: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Severe: Exception in thread "RateLimitExecutorDelayThread"
Severe: java.lang.NoSuchMethodError: com.google.common.util.concurrent.RateLimiter.acquire()D
at com.google.maps.internal.RateLimitExecutorService.run(RateLimitExecutorService.java:75)
at java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:0)
在pom.xml中将Google API版本更改为0.2.0,如下所示
<dependency>
<groupId>com.google.maps</groupId>
<artifactId>google-maps-services</artifactId>
<version>0.2.0</version>
''
这将解决您的问题