Search code examples
javagoogle-mapsgoogle-maps-api-3geolocationgeocoding

how to use google Geocoding in java?


I am developing a functionality for my project that when user enters 'Postal Code' the co-ordinates(latitude, longitude) for the corresponding 'postal code' should display. the implementation platform is 'JAVA'.

I googled for the java api but i did not find any specific resource.

Any suggstions will be greatly appriciated


Solution

  • It's quite straight forward. E.g. have a look at the geocode method of this class. Pass your postalcode (along with the country) to the method and you should be fine. (The GLatLng class can be found here but should be replaced by you according to your needs.)

    [edit] I just saw that this example is still using Google Maps v2, but it should be a breeze to convert it to v3. In the linked documents you can also find the restrictions regarding the use of this service (paragraph "Usage Limits")