GoogleDirectionAndPlaceLibrary icon indicating copy to clipboard operation
GoogleDirectionAndPlaceLibrary copied to clipboard

onDirectionSuccess is getting direction as REQUEST_DENIED

Open AvinashChowdary opened this issue 10 years ago • 2 comments

I tried to implement SimpleDirectionActivity and it is zooming to Origin as specified, but when I try to get directions it is getting direction to onDirectionSuccess as REQUEST_DENIED.

I also tried with different locations but no luck. Do you know why is this happening so ?? Thanks in advance.

AvinashChowdary avatar Dec 11 '15 07:12 AvinashChowdary

Did you already enable Google Maps Direction API in Google Developer Console?

akexorcist avatar Dec 15 '15 03:12 akexorcist

Yes I enabled it, I did some changes in your API call and I'm now able to get the results. Following are the changes

Direction Request:

Call<Direction> direction = DirectionAndPlaceConnection.createService().getDirection(param.getOrigin().latitude + "," + param.getOrigin().longitude, param.getDestination().latitude + "," + param.getDestination().longitude, param.getTransportMode(), param.getLanguage(), param.getAvoid(), param.getTransitMode(), true);

and in DirectionAndPlaceService :

@GET(DirectionUrl.DIRECTION_API_URL) Call<Direction> getDirection(@Query("origin") String origin, @Query("destination") String destination, @Query("mode") String transportMode, @Query("language") String language, @Query("avoid") String avoid, @Query("transit_mode") String transitMode, @Query("alternatives") boolean alternatives);

Now, I'm able to get the directions as required.

AvinashChowdary avatar Dec 15 '15 04:12 AvinashChowdary