ConnectionRequest r = new ConnectionRequest();
r.setPost(false);
r.addArgument("q", text);
r.addArgument("format", "json");
r.addArgument("addressdetails", "1");
// r.addArgument("limit", "1");
r.setDuplicateSupported(false);
r.setCacheMode(ConnectionRequest.CachingMode.SMART);
NetworkManager.getInstance().addToQueueAndWait(r);
result = new JSONParser().parseJSON(new InputStreamReader(new ByteArrayInputStream(r.getResponseData()), "UTF-8"));
tmpResult = (ArrayList) Result.fromContent(result).getAsArray("//root").get(0);
for (Object s : tmpResult) {
HashMap item = ((HashMap) s);
Place auxPlace = new Place();
Coord newCoord = new Coord(
Double.valueOf(item.get("lat").toString()),
Double.valueOf(item.get("lon").toString())
);
auxPlace.setPlaceName(item.get("display_name").toString());
auxPlace.setCoords(newCoord);
auxPlace.setPlace_id(item.get("place_id").toString());
records.add(auxPlace);
}
} catch (UnsupportedEncodingException ex) {
// Logger.getLogger(SearchLayer.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
// Logger.getLogger(SearchLayer.class.getName()).log(Level.SEVERE, null, ex);
} catch (IndexOutOfBoundsException ex) {
// Logger.getLogger(SearchLayer.class.getName()).log(Level.SEVERE, null, ex);
}