I wrote a process to get an address from latitude and longitude using GoogleMapsAPI. The Java SDK is provided by Google. It is a memo writing setting to return the address in Japanese.
https://github.com/googlemaps/google-maps-services-java
public String reverceGeocoding(double lat, double lon) {
LatLng latlng = new LatLng(lat, lon);
GeoApiContext context = new GeoApiContext.Builder().apiKey(apikey).build();
GeocodingApiRequest request = GeocodingApi.reverseGeocode(context, latlng).language("ja");
GeocodingResult[] results;
String address = null;
try {
results = request.await();
Gson gson = new GsonBuilder().setPrettyPrinting().create();
address = gson.toJson(results[0].formattedAddress);
} catch (ApiException | InterruptedException | IOException e) {
e.printStackTrace();
} finally {
context.shutdown();
}
return address;
}
There is nothing I can do once I make it, but I investigated how to specify the language. I will leave it as a reminder.
Recommended Posts