Skip to content

Commit 2706a86

Browse files
committed
Change double encoding for NEARBY_SEARCH (lat, lng and radius) because
in a not english server, the String.format can encode the double with a fractional separator other than . (dot). In French, for example, it's a coma (,).
1 parent cc5deee commit 2706a86

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ public void setRequestHandler(RequestHandler requestHandler) {
217217
@Override
218218
public List<Place> getNearbyPlaces(double lat, double lng, double radius, int limit, Param... extraParams) {
219219
try {
220-
String uri = buildUrl(METHOD_NEARBY_SEARCH, String.format(Locale.ENGLISH, "key=%s&location=%f,%f&radius=%f",
221-
apiKey, lat, lng, radius), extraParams);
220+
String uri = buildUrl(METHOD_NEARBY_SEARCH, String.format(Locale.ENGLISH, "key=%s&location=%s,%s&radius=%s",
221+
apiKey, String.valueOf(lat), String.valueOf(lng), String.valueOf(radius)), extraParams);
222222
return getPlaces(uri, METHOD_NEARBY_SEARCH, limit);
223223
} catch (Exception e) {
224224
throw new GooglePlacesException(e);
@@ -233,8 +233,8 @@ public List<Place> getNearbyPlaces(double lat, double lng, double radius, Param.
233233
@Override
234234
public List<Place> getNearbyPlacesRankedByDistance(double lat, double lng, int limit, Param... params) {
235235
try {
236-
String uri = buildUrl(METHOD_NEARBY_SEARCH, String.format(Locale.ENGLISH, "key=%s&location=%f,%f&rankby=distance",
237-
apiKey, lat, lng), params);
236+
String uri = buildUrl(METHOD_NEARBY_SEARCH, String.format(Locale.ENGLISH, "key=%s&location=%s,%s&rankby=distance",
237+
apiKey, String.valueOf(lat), String.valueOf(lng)), params);
238238
return getPlaces(uri, METHOD_NEARBY_SEARCH, limit);
239239
} catch (Exception e) {
240240
throw new GooglePlacesException(e);

0 commit comments

Comments
 (0)