尽管输入了数据,但Google place API始终返回1个对象

时间:2019-05-29 08:58:12

标签: java google-places-api

我有一个代码,可以在某些区域找到车载充电器。但是,尽管输入了数据,但即使半径很大,它也始终只会返回一个车载充电器。

我的方法:

 public FindPlaceFromText getChargers(LatLng center, int radius) {
    FindPlaceFromTextRequest req = PlacesApi.findPlaceFromText(context, "car charger",
            FindPlaceFromTextRequest.InputType.TEXT_QUERY)
            .fields(
                    FindPlaceFromTextRequest.FieldMask.PHOTOS,
                    FindPlaceFromTextRequest.FieldMask.FORMATTED_ADDRESS,
                    FindPlaceFromTextRequest.FieldMask.ID,
                    FindPlaceFromTextRequest.FieldMask.NAME,
                    FindPlaceFromTextRequest.FieldMask.PLACE_ID,
                    //FindPlaceFromTextRequest.FieldMask.RATING,
                    //FindPlaceFromTextRequest.FieldMask.OPENING_HOURS,
                    FindPlaceFromTextRequest.FieldMask.GEOMETRY)
            .locationBias(new FindPlaceFromTextRequest.LocationBiasCircular(center,radius));
    try {
        FindPlaceFromText results = req.awaitIgnoreError();
        return results;

        // Handle successful request.
    } catch (Exception e) {
        // Handle error
        System.out.println(e.toString());
        return null;
    }
}

我的测试方法:

@Test
public void createRespawnPoints() throws Exception{
Places places = new Places("api key ");
System.out.println(places.getChargers(new 
LatLng(55.751244,37.618423),5000000).candidates.length);
}

在输出中,我总是得到:

   1

我需要购买更多的车载充电器,如何解决?

0 个答案:

没有答案