googlemaps / google-maps-services-java Goto Github PK
View Code? Open in Web Editor NEWJava client library for Google Maps API Web Services
License: Apache License 2.0
Java client library for Google Maps API Web Services
License: Apache License 2.0
When using Proguard I can't retrieve Geocoding or Directions using this library. I can't find Proguard's rules for this library.
This is what I get when trying to Geocode:
com.google.maps.a.h: An unexpected error occurred. Status: null, Message: null
at com.google.maps.f.c(GeocodingApi.java:84)
at com.google.maps.b.i.a(OkHttpPendingResult.java:236)
at com.google.maps.b.i.onResponse(OkHttpPendingResult.java:183)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:168)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
And this is for Directions:
com.google.maps.a.h: An unexpected error occurred. Status: null, Message: null
at com.google.maps.b.c(DirectionsApi.java:69)
at com.google.maps.b.i.a(OkHttpPendingResult.java:236)
at com.google.maps.b.i.onResponse(OkHttpPendingResult.java:183)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:168)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
I have warnings about YodaTime, I tried with
-keep class org.joda.** { *; }
and
-dontwarn org.joda.convert.**
But it isn't working.
Hello guys,
I am working on a GAE backend which requires the DistanceMatrixAPI.
I am doing TDD, thus I've build my code and classes with tests first, and all the tests pass. Now I fire up my GAE server locally, and I have the following stack:
java.security.AccessControlException: access denied ("java.lang.RuntimePermission"
"modifyThreadGroup")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
at java.security.AccessController.checkPermission(AccessController.java:559)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:429)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkAccess(DevAppServerFactory.java:454)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
at java.lang.Thread.init(Thread.java:389)
at java.lang.Thread.init(Thread.java:349)
at java.lang.Thread.<init>(Thread.java:460)
at com.google.maps.internal.RateLimitExecutorService.<init>(RateLimitExecutorService.java:55)
at com.google.maps.GeoApiContext.setQueryRateLimit(GeoApiContext.java:224)
at com.google.maps.GeoApiContext.setQueryRateLimit(GeoApiContext.java:210)
at com.google.maps.GeoApiContext.<init>(GeoApiContext.java:56)
at com.techyos.jardibox.service.GoogleServicesHelper.requestDistances(GoogleServicesHelper.java:39)
at com.techyos.jardibox.service.ArchitectService.getMissingDistancesFromGoogleServices(ArchitectService.java:136)
at com.techyos.jardibox.service.ArchitectService.calculateDistances(ArchitectService.java:130)
at com.techyos.jardibox.service.ArchitectService.getAllDto(ArchitectService.java:73)
at com.techyos.jardibox.service.RegistrationService.mapDomainsToArchitects(RegistrationService.java:136)
at com.techyos.jardibox.service.RegistrationService.stepGetArchitects(RegistrationService.java:89)
at com.techyos.jardibox.controller.api.RegistrationApiController.stepGetArchitects(RegistrationApiController.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:491)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
My GoogleServiceHelper method looks like this:
public DistanceMatrix requestDistances(List<String> from, List<String> to) {
GeoApiContext context = new GeoApiContext().setApiKey(config.getGoogleApiKey());
try {
return DistanceMatrixApi.getDistanceMatrix(context,
from.toArray(new String[from.size()]),
to.toArray(new String[to.size()]))
.mode(TravelMode.DRIVING).await();
} catch (Exception e) {
logger.error("An error occured", e);
}
return null;
}
And the crash occures at the initialization of the GeoApiContext.
Is there a quick fix for this or am I just not supposed to use this client library in Google App Engine?
Thanks a lot in advance.
Hi,
I understand that this project is meant for Java server-side applications, hence Java on JVM code and not Java on Android code. I was wondering whether there is a plan to port this to Android, or make it Android compatible.
While the Google Maps API on Android is great, there is need to sometimes call the webservices from Android. That would be great to have.
Thanks,
Pulkit
I use DirectionsApi, but some place at transit mode will have Exception
for example
DirectionsRoute[] routes = DirectionsApi.newRequest(context)
.mode(TravelMode.TRANSIT)
.origin("Taipei 101")
.destination("Tainan")
.await();
and it will throw an error
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a name but was STRING at line 17 column 23 path $.routes[0].fare.text
some place's direction is okay but some will go wrong
I don't know why
I have access google api through proxy with authentication, but there seems no method in GeoApiContext could set authentication for OkClient.
I want to know if there is a way to do this?
Thanks
I am extensively using the Geocoding API for a uni project (~ 30000 requests per day), and I often see these kind of exceptions:
INFO: Request: https://maps.googleapis.com/maps/api/geocode/json?key=mykey&address=Some+address
Sep 30, 2015 5:42:04 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #1
Sep 30, 2015 5:42:04 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #2
Sep 30, 2015 5:42:05 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #3
Sep 30, 2015 5:42:07 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #4
Sep 30, 2015 5:42:10 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #5
Sep 30, 2015 5:42:12 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #6
Sep 30, 2015 5:42:16 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #7
Sep 30, 2015 5:42:20 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #8
Sep 30, 2015 5:42:29 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #9
Sep 30, 2015 5:42:45 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #10
Sep 30, 2015 5:42:58 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #11
com.google.maps.errors.UnknownErrorException
at com.google.maps.errors.ApiException.from(ApiException.java:50)
at com.google.maps.GeocodingApi$Response.getError(GeocodingApi.java:84)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:236)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.internal.OkHttpPendingResult.retry(OkHttpPendingResult.java:263)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:194)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.internal.OkHttpPendingResult.retry(OkHttpPendingResult.java:263)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:194)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.internal.OkHttpPendingResult.retry(OkHttpPendingResult.java:263)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:194)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.internal.OkHttpPendingResult.retry(OkHttpPendingResult.java:263)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:194)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.internal.OkHttpPendingResult.retry(OkHttpPendingResult.java:263)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:194)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.internal.OkHttpPendingResult.retry(OkHttpPendingResult.java:263)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:194)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.internal.OkHttpPendingResult.retry(OkHttpPendingResult.java:263)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:194)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.internal.OkHttpPendingResult.retry(OkHttpPendingResult.java:263)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:194)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.internal.OkHttpPendingResult.retry(OkHttpPendingResult.java:263)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:194)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.internal.OkHttpPendingResult.retry(OkHttpPendingResult.java:263)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:194)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.internal.OkHttpPendingResult.retry(OkHttpPendingResult.java:263)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:194)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152)
at com.google.maps.PendingResultBase.await(PendingResultBase.java:56)
at com.my.package.MyClass$1.getCoordinates(MyClass.java:70)
...
I can see why you repeat the request for n
times, but I'd like to lower that threshold, as it freezes my pipeline for too long. I have also noticed that when errors are repeated for more than 2-3 times, it's probably due to some server error that doesn't fix itself in the next attempts (i.e. my requests are always attempted 1 or 11 times).
Is there a way to lower the retry quantity?
Hi everybody,
It's quite my beggining in Github so excuse me in advance if I missuse it right now.
Actually I wonder if there is any way to set a Channel on the GeoApiContext. It's really useful for me to follow the usage and quotas of my Google Maps For Work end users.
Thanks in advance for any answers !
Create this enum type.
I'd like to override my base URL, in order to call a VIP instead of directly the GMap URL...
I can see a private attribute 'baseUrlOverride' but it's on visibility package, and for test purpose. It will be interesting to allow users to configure this URL.
Data is returning partialMatch = false
, test is expecting partialMatch = true
.
ping @domesticmouse @broady
For example, postal_code_suffix / postal_code_prefix are not documented here but it still probably adds value having them in the library.
Let's mark them as @Deprecated
Hi to all, and thank's for this work .......
i've a problem,
using the quartz scheduler, my app invoke 2000 reverse geocoding service
( obviusly under free limit quota )
with sychronous req.await() method.....
after these 2000 call ... in jvm i've 2000 thead alive with name Thread-1 .... Thread-2000 that make too slow system ( server centOs 6 and tomcat 7.... jdk 1.7)
please, a suggestion??
thank's in advance.
best regards
Aldo
What package is okio.Sink?
I get this while trying your example shown in the readme.
Exception in thread "Rate Limited Dispatcher" java.lang.NoClassDefFoundError: okio/Sink
at com.squareup.okhttp.Call.getResponse(Call.java:252)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:219)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:192)
at com.squareup.okhttp.Call.access$100(Call.java:34)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:156)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassNotFoundException: okio.Sink
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 9 more
I already implemented gson and okhttp.
Any suggestions?
Thank you.
I'm using Java 6 and have this issue at runtime
java.lang.UnsupportedClassVersionError: com/google/maps/GeoApiContext : Unsupported major.minor version 51.0 (unable to load class com.google.maps.GeoApiContext)
My pom.xml
com.google.maps
google-maps-services
0.1.3
It seems the JAR file is compiled with Java 7. Please support Java 6. Thanks.
#37 was closed but never fixed. Please add this enum value.
I have downloaded okhttp and google-maps-services jar files.
Google-maps-services is reporting a 'NoClassDefFoundError' on OkhttpClient.
I am using JDK 1.7. Any issue what the issue is? Thanks.
More specifically I am attempting to use javac via command line to build the classes. Here is what I did:
"This IP, site or mobile application is not authorized to use this API key" makes sense, but it would be nice to know which IP is being sent.
Constructive error message would help educate user on steps to be taken for resolving this error.
I am to get the actual distance between two points / coordinates using REST web services call like following
http://maps.googleapis.com/maps/api/distancematrix/json?origins=54.406505,18.67708&destinations=54.446251,18.570993&mode=driving&language=en-EN&sensor=false
{ "destination_addresses" : [ "Kuby Kwiatkowskiego, Sopot, Poland" ], "origin_addresses" : [ "Majora Henryka Sucharskiego 70, 80-601 Gdańsk, Poland" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "24.4 km", "value" : 24412 }, "duration" : { "text" : "38 mins", "value" : 2300 }, "status" : "OK" } ] } ], "status" : "OK" }
But now I would like to get the "traveling distance" between them, how can I get this? Please guide me asap.
I got some news from some places that some API's from google maps will not longer be supported and maybe they will be replaced with "mymaps" API's. So I will like to know if these API's are still working fine.
For one of my requests, the JSON response includes:
{
"long_name" : "6863",
"short_name" : "6863",
"types" : [ "postal_code_suffix" ]
}
Which produces the following stack trace:
Exception in thread "main" java.lang.RuntimeException: Unknown address component type 'postal_code_suffix'
at com.google.maps.model.AddressComponentType.lookup(AddressComponentType.java:294)
at com.google.maps.internal.AddressComponentTypeAdapter.read(AddressComponentTypeAdapter.java:46)
at com.google.maps.internal.AddressComponentTypeAdapter.read(AddressComponentTypeAdapter.java:33)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:95)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:183)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:95)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:183)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:95)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:183)
at com.google.gson.Gson.fromJson(Gson.java:805)
at com.google.gson.Gson.fromJson(Gson.java:743)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:224)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:159)
at com.google.maps.PendingResultBase.await(PendingResultBase.java:55)
at com.harrisonstreetsoftware.apps.App.main(App.java:93)
Hi,
We are using google-maps-services library (v. 0.1.7) in production enviroments and we discovered to much thread "opened" in our JVMs.
We did a thread dump and we find out the a lot of Thread (200) in the following situation:
"Thread-51224" daemon prio=10 tid=0x00007f8e6c32d000 nid=0x1b6e waiting on condition [0x00007f8eddbea000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x0000000786ea7638> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at com.google.maps.internal.RateLimitExecutorService.run(RateLimitExecutorService.java:88)
at java.lang.Thread.run(Thread.java:745)
We have very very few traffic on our application. (Some requests for days)
Can you help us to understand the issue?
Regards
From https://developers.google.com/maps/documentation/directions/ -->
You can use waypoints to influence your route without adding a stopover by prefixing the waypoint with via:. Waypoints prefixed with via: will not add an additional leg to the route.
Sample Request:
https://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|via:Lexington,MA&key=API_KEY
For now, I think it's only possible to get duration in traffic. Would be very convenient if that could be turned off.
Expected :L[Ä«huÊ»]e, HI 96766, USA
Actual :L[?hu?]e, HI 96766, USA
org.junit.ComparisonFailure: expected:<L[\u012bhu\u02bb]e, HI 96766, USA> but was:<L[?hu?]e, HI 96766, USA>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at com.google.maps.GeocodingApiTest.testUtfResult(GeocodingApiTest.java:273)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:105)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:56)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:64)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Hi
We have been using this package for a few weeks without any issues but its suddenly not working with a message 403 forbidden. Normally i would put this down to usage limits etc however if i take the URL that appears in my log with the client id and signature and post it in my browser the service responds as normal with a 200 and the results
Can anyone point me in the right direction as i really don't want to have pull this package back out of my code base, but it only seems to have an issue when i use this package
Thanks
This project indicates that Java 6 is minimally required (and is specified in the Gradle dependcies), but the project's dependency on okhttp 2.0 (which is compiled on Java 7) effectively makes this project require Java 7 in my server environment. I tried modifying the Gradle dependencies to indicate a dependency on okhttp 1.6.0 (which is the latest okhttp version that uses Java 6), but then the project couldn't compile (with 27 or so compile errors) probably because of the API changes in okhttp 1.6.0 to 2.0.0. I tried this on the v0.1.5 maintenance release tag and also the latest code - and all your old code when I looked at the tags all the way back to v0.1.1 requires okhttp 2.0 as well.
As proof, when I compile with JDK 6:
./gradlew jar
:updateVersion
:compileJava
warning: com/squareup/okhttp/Dispatcher.class(com/squareup/okhttp:Dispatcher.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: com/squareup/okhttp/OkHttpClient.class(com/squareup/okhttp:OkHttpClient.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: com/squareup/okhttp/Request.class(com/squareup/okhttp:Request.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: com/squareup/okhttp/Call.class(com/squareup/okhttp:Call.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: com/squareup/okhttp/Callback.class(com/squareup/okhttp:Callback.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: com/squareup/okhttp/Response.class(com/squareup/okhttp:Response.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: com/squareup/okhttp/Request$Builder.class(com/squareup/okhttp:Request$Builder.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: com/squareup/okhttp/ResponseBody.class(com/squareup/okhttp:ResponseBody.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
8 warnings
:processResources UP-TO-DATE
:classes
:jar
Then when I run the tests:
./gradlew test
:updateVersion UP-TO-DATE
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava
Note: /home/myhome/workspace/google-maps-services-java/src/test/java/com/google/maps/GeoApiContextTest.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:processTestResources UP-TO-DATE
:testClasses
:test
com.google.maps.GeoApiContextTest > testErrorResponseRetries FAILED
java.lang.UnsupportedClassVersionError at GeoApiContextTest.java:42
com.google.maps.GeoApiContextTest > testRetryCanBeDisabled FAILED
java.lang.UnsupportedClassVersionError at GeoApiContextTest.java:42
com.google.maps.GeoApiContextTest > testRetryEventuallyReturnsTheRightExceptionFAILED
java.lang.UnsupportedClassVersionError at GeoApiContextTest.java:42
com.google.maps.GeoApiContextTest > testGetIncludesDefaultUserAgent FAILED
java.lang.UnsupportedClassVersionError at GeoApiContextTest.java:42
com.google.maps.ElevationApiTest > testGetByPointsThrowsRequestDeniedExceptionFromResponse FAILED
java.lang.UnsupportedClassVersionError at ElevationApiTest.java:35
com.google.maps.ElevationApiTest > testGetByPointThrowsInvalidRequestExceptionFromResponse FAILED
java.lang.UnsupportedClassVersionError at ElevationApiTest.java:35
com.google.maps.DistanceMatrixApiTest > testTravelModeRejectsInvalidMode FAILED
java.lang.UnsupportedClassVersionError at DistanceMatrixApiTest.java:37
com.google.maps.DistanceMatrixApiTest > testLatLngOriginDestinations FAILED
java.lang.UnsupportedClassVersionError at DistanceMatrixApiTest.java:37
com.google.maps.DistanceMatrixApiIntegrationTest > initializationError FAILED
java.lang.IllegalArgumentException
com.google.maps.DirectionsApiTest > initializationError FAILED
java.lang.IllegalArgumentException
com.google.maps.TimeZoneApiTest > initializationError FAILED
java.lang.IllegalArgumentException
com.google.maps.ElevationApiIntegrationTest > initializationError FAILED
java.lang.IllegalArgumentException
com.google.maps.GeocodingApiTest > initializationError FAILED
java.lang.IllegalArgumentException
19 tests completed, 13 failed, 1 skipped
:test FAILED
FAILURE: Build failed with an exception.
This is probably a request that may be ignored, but could you modify the code to have a dependency on okhttp 1.6.0 instead?
If the web services return OverQueryLimitException
these lines in the OKHttpPenedingResult.java
ApiException e = resp.getError();
if(e instanceof OverQueryLimitException && this.cumulativeSleepTime < this.errorTimeOut) {
return request.retry();
} else {
throw e;
}
Will make the call retry() and the onFailure or onResult are not being called.
Hi,
I am new to using maps so I'm not sure if I have this right but I am writing an android app and as far as I can tell it would be better for me to not use an API key for my requests and instead rely on the IP address usage limits.
It looks like this library does not allow this.
Just wondering if this could be added as an option.
Cheers
I am getting a NumberFormatException when requesting speed limits within the USA. The API specifies the speedLimit property to be in kilometers per hour, so a float must be returned to provide a decent amount of accuracy when converted in miles per hour.
It as simple as changing com.google.maps.model.SpeedLimit
's speedLimit property from a long
to a double
. I can provide a pull request if needed.
@Test
public void testSpeedLimitsWithUSALatLngs() throws Exception {
SpeedLimit[] speeds = RoadsApi.speedLimits(context,
new LatLng(28.361803, -81.518966),
new LatLng(33.777622, -84.397788),
new LatLng(40.758810, -73.984928),
new LatLng(38.907472, -77.036525),
new LatLng(37.682462, -97.332222),
new LatLng(37.420978, -122.084389),
new LatLng(33.809636, -117.915440)).await();
assertNotNull(speeds);
assertEquals(7, speeds.length);
for (SpeedLimit speed : speeds) {
assertNotNull(speed.placeId);
assertTrue(speed.speedLimit > 0);
}
}
com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: Expected a long but was 56.327042 at line 5 column 30 path $.speedLimits[0].speedLimit at com.google.gson.internal.bind.TypeAdapters$8.read(TypeAdapters.java:263) at com.google.gson.internal.bind.TypeAdapters$8.read(TypeAdapters.java:253) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40) at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196) at com.google.gson.Gson.fromJson(Gson.java:810) at com.google.gson.Gson.fromJson(Gson.java:775) at com.google.gson.Gson.fromJson(Gson.java:724) at com.google.gson.Gson.fromJson(Gson.java:696) at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:217) at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:152) at com.google.maps.RoadsApiIntegrationTest.testSpeedLimitsWithUSALatLngs(RoadsApiIntegrationTest.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runners.Suite.runChild(Suite.java:127) at org.junit.runners.Suite.runChild(Suite.java:26) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: java.lang.NumberFormatException: Expected a long but was 56.327042 at line 5 column 30 path $.speedLimits[0].speedLimit at com.google.gson.stream.JsonReader.nextLong(JsonReader.java:980) at com.google.gson.internal.bind.TypeAdapters$8.read(TypeAdapters.java:261) ... 45 more
The LatLng class doesn't have a no-arg constructor, and gson can't handle this. The following exception is thrown:
Caused by: java.lang.RuntimeException: Unable to invoke no-args constructor for class com.google.maps.model.LatLng. Register an InstanceCreator with Gson for this type may fix this problem.
at com.google.gson.internal.ConstructorConstructor$12.construct(ConstructorConstructor.java:210)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:186)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196)
at com.google.gson.Gson.fromJson(Gson.java:810)
at com.google.gson.Gson.fromJson(Gson.java:748)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:222)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:155)
at com.google.maps.PendingResultBase.await(PendingResultBase.java:55)
The problem appears as soon as the location information of a geo request is accessed:
GeocodingResult[] geo = GeocodingApi.geocode(context, "Some address").await();
System.out.println(geo[0].geometry.location.lat);
Hi, maintainers!
I just wanted to let you know that package (as it seems for me) is a little bit to cautious about hiding everything it can. I do understand why you may not want end user to mess with internals, but you also prohibit end user from extending package and implementing missing features. For example, i want to perform nearbysearch
from Places API, but i can't implement my own request, because base request classes are invisible for outside world, so i need to build API from scratch, while i could simply integrate my own type of request into existing system.
I know that i can do a pull request, then wait for release or even bring up my own maven repo, but, unfortunately, i don't have that much of time.
Making a NearbySearchRequest.type replace the last type selected. It must be appended using the pipe, for example, church|food.
NearbySearchRequest nearbySearchRequest = new NearbySearchRequest(geoApiContext);
nearbySearchRequest.type(PlaceType.CHURCH);
nearbySearchRequest.type(PlaceType.LODGING);
It would be useful to be able to set the HTTP referrer, as an additional security measure and for better flexibility.
In response to this query: https://maps.googleapis.com/maps/api/geocode/json?address=800+Huntington+Ave%2C+Boston%2C+MA+2115, one of the address types returned is "university" which the library does not understand.
Exception in thread "main" java.lang.RuntimeException: Unknown address type 'university'
at com.google.maps.model.AddressType.lookup(AddressType.java:249)
at com.google.maps.internal.AddressTypeAdapter.read(AddressTypeAdapter.java:46)
at com.google.maps.internal.AddressTypeAdapter.read(AddressTypeAdapter.java:33)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:95)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:183)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:95)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:183)
at com.google.gson.Gson.fromJson(Gson.java:805)
at com.google.gson.Gson.fromJson(Gson.java:743)
at com.google.maps.internal.OkHttpPendingResult.parseResponse(OkHttpPendingResult.java:224)
at com.google.maps.internal.OkHttpPendingResult.await(OkHttpPendingResult.java:159)
at com.google.maps.PendingResultBase.await(PendingResultBase.java:55)
Hi, I just have a very stupid question:
I have created a java application like this:
package test;
import com.google.maps.DistanceMatrixApi;
import com.google.maps.GeoApiContext;
import com.google.maps.GeocodingApi;
import com.google.maps.model.DistanceMatrix;
import com.google.maps.model.DistanceMatrixRow;
import com.google.maps.model.GeocodingResult;
import com.google.maps.model.TravelMode;
public class TestGoogle {
public static void main(String[] args) {
GeoApiContext context = new GeoApiContext().setApiKey("AIz***");
GeocodingResult[] results;
try {
results = GeocodingApi.geocode(context,"1600 Amphitheatre Parkway Mountain View, CA 94043").await();
System.out.println(results[0].formattedAddress);
} catch (Exception e) {
e.printStackTrace();
}
}
}
But when I ran it, I got an error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/squareup/okhttp/OkHttpClient
at com.google.maps.GeoApiContext.(GeoApiContext.java:49)
at test.TestGoogle.main(TestGoogle.java:40)
Caused by: java.lang.ClassNotFoundException: com.squareup.okhttp.OkHttpClient
Do you know, what could be the reason? I have tried with both server key and browser key.
Thank you!
I've reached my daily limit of 2500 reqs for the directions api, and the client seems to get stuck retrying the call over and over again. I would have expected an exception thrown since this is not recoverable, am I wrong in assuming this?
Relevant parts of my code:
this.geoApiContext = new GeoApiContext();
this.geoApiContext.setApiKey(googleApiKey);
...
DirectionsRoute[] routes = DirectionsApi
.getDirections(geoApiContext, origin, destination)
.units(Unit.METRIC)
.await();
This prints to the console:
Jan 19, 2016 10:30:35 PM com.google.maps.GeoApiContext getWithPath
INFO: Request: https://maps.googleapis.com/maps/api/directions/json?key=somekey&origin=-34.6202964%2C-58.5139567&destination=-34.5757411%2C-58.463964&units=metric
Jan 19, 2016 10:31:02 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #1
Jan 19, 2016 10:31:04 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #2
Jan 19, 2016 10:31:05 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #3
Jan 19, 2016 10:31:07 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #4
Jan 19, 2016 10:31:11 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #5
Jan 19, 2016 10:31:13 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #6
Jan 19, 2016 10:31:18 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #7
Jan 19, 2016 10:31:26 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #8
Jan 19, 2016 10:31:34 PM com.google.maps.internal.OkHttpPendingResult retry
INFO: Retrying request. Retry #9
Disconnected from the target VM, address: '127.0.0.1:50148', transport: 'socket'
thanks
Is it possible to get directions of, say, List? I know there is a method getDirections(GeoApiContext context, java.lang.String origin, java.lang.String destination) in DirectionsApi, but it would be nice if there would be a method in DirectionsApi getDirections(GeoApiContext context, List path), but it would be necessary to create another getDirections(GeoApiContext context, LatLng origin, LatLng destination);
Would it be possible?
Thanks
I am not sure if I haven't missed something but I am afraid I can not restrict place type like geocode, address, establishment, etc as described in Table 3 here. PlaceType enum contains only values from Table 1 and I can't find other way to do this.
Please let me know the right way to do this if I am wrong. Thank you.
I get this when calling GeocodingApi.reverseGeocode ...
nov 21, 2015 12:39:01 EM com.google.maps.internal.SafeEnumAdapter read
VARNING: Unknown type for enum com.google.maps.model.AddressType: 'postal_town'
.. and I am using the latest and greatest version 0.1.9
The request URL generated by this lib put the API key as the first parameter in the URL whereas on the Google Maps service side it requires to put the API key at the end of the URL or a com.google.maps.errors.RequestDeniedException will be thrown.
A local_icon field is available for vehicle in transit details. It could be very useful but it's not documented (doc).
For instance in Paris we have:
What do you think about it? Can we add this field?
Java in GAE is a "sandboxed" version and the sandbox does not allow creating new threads:
https://cloud.google.com/appengine/docs/java/?csw=1#Java_The_sandbox
https://github.com/googlemaps/google-maps-services-java/blob/master/src/main/java/com/google/maps/internal/RateLimitExecutorService.java#L58 causes access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
(full stack trace below)
To fix this we should follow the instructions from: https://cloud.google.com/appengine/docs/java/?csw=1#Java_The_sandbox
Should we maybe work around this so that the lib works on appengine?
At least can we add a custom error message suggestion this might be the root cause?
access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
Caused by:
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
at java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:429)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkAccess(DevAppServerFactory.java:454)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
at java.lang.Thread.init(Thread.java:391)
at java.lang.Thread.init(Thread.java:349)
at java.lang.Thread.(Thread.java:461)
at com.google.maps.internal.RateLimitExecutorService.(RateLimitExecutorService.java:55)
at com.google.maps.GeoApiContext.setQueryRateLimit(GeoApiContext.java:224)
at com.google.maps.GeoApiContext.setQueryRateLimit(GeoApiContext.java:210)
at com.google.maps.GeoApiContext.(GeoApiContext.java:56)
at com.sellbytel.geo.WebServicesJavaClientLib.GeoWsSamples.testGeocodeSimple(GeoWsSamples.java:213)
at org.apache.jsp.geocodesimple_jsp._jspService(geocodesimple_jsp.java:70)
Hi, i'm getting quite usual warning message:
WARNING: Unknown type for enum com.google.maps.model.AddressComponentType: 'subway_station'
I guess this may be fixed by simply listing that value in appropariate enum (or enums, i think AddressType should be patched as well).
Thank you!
Places autocomplete supports more parameters like place types
and components
as described on
https://developers.google.com/places/web-service/autocomplete
I want to use client ID and secret to authenticate for Roads API,
but in RoadsAPI.java
, it set supportsClientId as false:
Why Roads API not supports ClientID?
And is it possible to use ClientID for Roads API?
Regards,
I'm using GeocodingAPI in Japan.
I encountered following messages in a warn log.
2016-01-04 06:15:31.659 WARN 15968 --- [xxx] c.google.maps.internal.SafeEnumAdapter : Unknown type for enum com.google.maps.model.AddressComponentType: 'ward'
2016-01-04 06:15:31.660 WARN 15968 --- [xxx] c.google.maps.internal.SafeEnumAdapter : Unknown type for enum com.google.maps.model.AddressType: 'ward'
Is it possible to define WARD enum item to AddressType/AddressComponentType?
In Google Developers' documentation ( https://developers.google.com/maps/documentation/geocoding/intro#Types ), ward
is described as follows:
ward
indicates a specific type of Japanese locality, to facilitate distinction between multiple locality components within a Japanese address.
Regards,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.