我正在制作一个android应用程序,需要在我10km以内的本地区域进行搜索,并使用引脚将结果显示在地图上,例如:“Starbucks”,“Wallmart”,Shopping mall等。我在我的活动类中指定的搜索词。并且要清楚:我不想在Google地图中打开搜索,我希望它能在我自己的应用程序中显示结果。但是我在执行搜索的代码中出现错误。错误出现在以下东西:Google Places API - android
网址:网址不能得到解决或不是一个场 执行:该方法执行()是未定义的类型的HttpRequest 响应:响应不能得到解决或不是一个场
我使用三个包: com.mycompany.applicationname =默认包,其中包含主代码,包括搜索码 com.mycompany.applicationname.Model =含PlaceAutoComplete,PlacesList,地点等 com.mycompany .applicationname.PlacesRequests =包含PlaceRequest.java
请帮助我,我真的需要帮助,感谢这么多提前
这是我使用来执行搜索代码:
private static final String PLACES_SEARCH_URL = "https://maps.googleapis.com/maps/api/place/search/json?";
private static final boolean PRINT_AS_STRING = false;
public void performSearch() throws Exception {
try {
System.out.println("Perform Search ....");
System.out.println("-------------------");
HttpRequestFactory httpRequestFactory = createRequestFactory(transport);
HttpRequest request = httpRequestFactory.buildGetRequest(new GenericUrl(PLACES_SEARCH_URL));
request.url.put("key", API_KEY);
request.url.put("location", lat + "," + lng);
request.url.put("radius", 500);
request.url.put("sensor", "false");
if (PRINT_AS_STRING) {
System.out.println(request.execute().parseAsString());
} else {
PlacesList places = request.execute().parseAs(PlacesList.class);
System.out.println("STATUS = " + places.status);
for (Place place : places.results) {
System.out.println(place);
}
}
} catch (HttpResponseException e) {
System.err.println(e.response.parseAsString());
throw e;
}
}