【发布时间】:2018-02-18 20:26:04
【问题描述】:
我想将纬度和经度值传递给 Google Maps Autocomplete API 调用的 location 属性,但我不知道如何在 Retrofit 中形成 GET 调用。 URL 最终应如下所示:
https://maps.googleapis.com/maps/api/place/autocomplete/json?&types=address&input=user_input&location=37.76999,-122.44696&radius=50000&key=API_KEY
我目前在我的 Retrofit 界面中有什么:
public interface GooglePlacesAutoCompleteAPI
{
String BASE_URL = "https://maps.googleapis.com/maps/api/place/autocomplete/";
String API_KEY = "mykey"; //not the actual key obviously
//This one works fine
@GET("json?&types=(cities)&key=" + API_KEY)
Call<PlacesResults> getCityResults(@Query("input") String userInput);
//This is the call that does not work
@GET("json?&types=address&key=" + API_KEY)
Call<PlacesResults> getStreetAddrResults(@Query("input") String userInput,
@Query("location") double latitude, double longitude,
@Query("radius") String radius);
}
我的错误是:java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #3) for method GooglePlacesAutoCompleteAPI.getStreetAddrResults
那么如何正确设置getStreetAddrResults() 的GET 方法?
另外,我的数据类型对于纬度/经度和半径是否正确?感谢您的帮助!
【问题讨论】:
标签: android google-maps retrofit google-places-api