Scenario
We want to return one candidate in the Thai language, within 100 feet of the point. Call the reverse geocoding java api and override the preferences for search distance and max candidates.
Request
double latitude = 16.471625;
double longitude = 99.53375;
String coordsysName = "epsg:4326";
Preferences preferences = new GeocoderPreferences();
preferences.setReturnAllCandidateInfo(true);
preferences.setClientLocale(Locale.forLanguageTag("th-TH"));
preferences.setDistance(100);
preferences.setDistanceUnits(DistanceUnit.FEET);
preferences.setMaxReturnedCandidates(1);
System.out.println("number of matches: " + response.getTotalPossibleCandidates());
if (response.getTotalMatches() > 0) {
for (Candidate candidate : response.getCandidates())
{ System.out.println("mainAddressLine: " + candidate.getFormattedStreetAddress());
System.out.println("addressLastLine: " + candidate.getFormattedLocationAddress());
System.out.println("precisionCode: " + candidate.getPrecisionCode());
System.out.println("latitude:" + candidate.getPoint().getY());
System.out.println("longitude:" + candidate.getPoint().getX()); }
}
Response
number of matches: 1
mainAddressLine: ถนนบำรุงราษฎร์
addressLastLine: ในเมือง จ.กำแพงเพชร 62000
precisionCode: RS4A
latitude:16.471625
longitude:99.53375