Skip to content

Commit 604d6c6

Browse files
committed
Fix issue #21.
1 parent d2ea064 commit 604d6c6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/main/java/se/walkercrou/places/GooglePlaces.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public List<Place> getPlacesByRadar(double lat, double lng, double radius, int l
248248
try {
249249
String uri = buildUrl(METHOD_RADAR_SEARCH, String.format(Locale.ENGLISH, "key=%s&location=%f,%f&radius=%f",
250250
apiKey, lat, lng, radius), extraParams);
251-
return getPlaces(uri, METHOD_RADAR_SEARCH, limit);
251+
return getRadarPlaces(uri, METHOD_RADAR_SEARCH, limit);
252252
} catch (Exception e) {
253253
throw new GooglePlacesException(e);
254254
}
@@ -392,7 +392,6 @@ public List<Prediction> getQueryPredictions(String input, Param... extraParams)
392392
}
393393

394394
private List<Place> getPlaces(String uri, String method, int limit) throws IOException {
395-
396395
limit = Math.min(limit, MAXIMUM_RESULTS); // max of 60 results possible
397396
int pages = (int) Math.ceil(limit / (double) MAXIMUM_PAGE_RESULTS);
398397

@@ -417,6 +416,17 @@ private List<Place> getPlaces(String uri, String method, int limit) throws IOExc
417416
return places;
418417
}
419418

419+
private List<Place> getRadarPlaces(String uri, String method, int limit) throws IOException {
420+
limit = Math.min(limit, MAXIMUM_RADAR_RESULTS); // max of 200 results possible
421+
422+
List<Place> places = new ArrayList<>();
423+
String raw = requestHandler.get(uri);
424+
debug(raw);
425+
parse(this, places, raw, limit);
426+
427+
return places;
428+
}
429+
420430
private void sleep(long millis) {
421431
try {
422432
Thread.sleep(millis);

src/main/java/se/walkercrou/places/GooglePlacesInterface.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public interface GooglePlacesInterface extends Types, Statuses {
2929
* The maximum results that can be returned.
3030
*/
3131
int MAXIMUM_RESULTS = 60;
32+
33+
/**
34+
* The maximum radar results that can be returned.
35+
*/
36+
int MAXIMUM_RADAR_RESULTS = 200;
3237

3338
/**
3439
* The maximum search radius for places.

0 commit comments

Comments
 (0)