我还是谷歌新手,我发现我的应用程序面临诸如您必须使用API密钥来验证每个Google Map Platforms API请求的问题。我想我需要在改造客户端中添加API密钥以获取密钥,但我不知道如何做到这一点。
我已经调试了我的应用程序,它可以获取当前位置,如(lat,lng),但无法通过JsonObject并说它需要API密钥。我在chrome中测试过,我在URL中获得的地址需要添加一个键,它可以得到如下位置:Link
public interface IGeoCoordinates {
@GET("maps/api/geocode/json")
Call<String> getGeoCode(@Query("address") String address);
@GET("maps/api/directions/json")
Call<String> getDirections(@Query("origin") String origin, @Query("destination") String destination);
}
像这样:
@GET("/maps/api/geocode/json?sensor=true&language=EN")
Observable<TheResponse> getGeocoding(
@Query("latlng") String latLng,
@Query("key") String key);
基本上你只需要添加@Query("key") String key
并提供它。