1

Hello I am building an app in Java and I would like to get the latitude/longitude from a string address.

Every tutorials I found was quite old and doesn't seem to be the more "up-to-date" solution nowadays...

I guess I should use the Jackson API to convert JSON result to Java object after requesting Google Geocoding API which returns me results like these JSON response

According to this tutorial Jackson convert JSON to Java object here is what I should use:

ObjectMapper mapper = new ObjectMapper();
Staff obj = mapper.readValue(new URL("http://mkyong.com/api/staff.json"), Staff.class);

What I don't understand is if the "Staff class" ( which in my case will probably be a "Address class" ) should contains every attribute such as excepted in the JSON response or can I just choose those I am interested in ( lat/long) ?

Am I on the right way ?

EDIT : It is not an android project

Helvin
  • 43
  • 1
  • 9
  • [this one](https://developer.android.com/reference/android/location/Geocoder.html#getFromLocationName(java.lang.String,%20int)) worked for me. you can also check this [answer](http://stackoverflow.com/questions/15711499/get-latitude-and-longitude-with-geocoder-and-android-google-maps-api-v2) – ebanouz Aug 05 '16 at 14:31
  • see http://stackoverflow.com/questions/5455014/ignoring-new-fields-on-json-objects-using-jackson –  Aug 05 '16 at 14:33
  • Is the example you show specific to android ? – Helvin Aug 05 '16 at 14:33
  • right, i thought you asked about android, sorry :) – ebanouz Aug 05 '16 at 14:38
  • Check this: http://stackoverflow.com/questions/3574644/how-can-i-find-the-latitude-and-longitude-from-address – Android Enthusiast Aug 06 '16 at 18:50
  • Once again the link you mentionned is about android :/ – Helvin Aug 07 '16 at 11:46
  • 1
    possible duplication of: http://stackoverflow.com/questions/7265833/how-to-serialize-and-deserialize-a-json-object-from-google-geocode-using-java – Hash Aug 08 '16 at 14:10
  • Thank you very much this is the thread I was looking for ! I do have my answer now ! – Helvin Aug 08 '16 at 17:18

0 Answers0