我没有Elevations API密钥来测试这一点,但使用的是改装的
documentation
,像这样的东西应该有用。
@GET("/maps/api/elevation/json")
public Call<List<JsonElevation>> getJSON(@Query("locations") String latAndLng,
@Query("key") String key);
那么就称之为:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://maps.googleapis.com/")
.addConverterFactory(GsonConverterFactory.create(new Gson()))
.build();
ServiceApi serviceApi = retrofit.create(ServiceApi.class);
String latAndLng = String.format("%f,%f", latitude, longitude);
Call<List<JsonElevation>> elevations = serviceApi.getJSON(latAndLng, key);
elevations.enqueue(); // for asychronous response
//or
elevations.execute(); // for synchronous response