A Spring Boot microservice that provides coordinates from a ZIP code and lists nearby banks using the Google Maps API. This service is consumed by the bank-service.
com.nearbybank.maps
├── config # Configuration classes
├── controller # REST API endpoints
├── integration # Google Maps API integration
├── model # POJOs for Google Maps response and Bank info
├── service # Business logic to process coordinates and banks
├── MapsServiceApplication.java # Main class
└── resources
└── application.properties # Configurations
Returns [latitude, longitude] for a given ZIP code by calling Google Geocoding API.
MapsController→MapsService→GoogleMapsClient- Uses
https://maps.googleapis.com/maps/api/geocode/json - Returns latitude & longitude as a String array.
Returns a list of nearby banks around the given latitude and longitude (within 10 miles).
MapsController→MapsService→GoogleMapsClient- Uses
https://maps.googleapis.com/maps/api/place/nearbysearch/json - Filters and returns a list of
Bankobjects.
[
{
"name": "Chase Bank",
"address": "123 Main St, New York, NY",
"latitude": "40.7128",
"longitude": "-74.0060"
},
{
"name": "Bank of America",
"address": "456 6th Ave, New York, NY",
"latitude": "40.7132",
"longitude": "-74.0055"
}
]- This microservice talks directly to Google Maps APIs using
RestTemplate. - Reads the Google API key from
.envfile usingDotenv. - Handles both:
- ZIP to Coordinates (via Geocoding API)
- Coordinates to Banks (via Places API)
- Clean separation of concerns using:
controllerfor endpoints,servicefor logic,integrationfor external API calls,modelfor mapping API responses
- Import the project as a Gradle Project into Eclipse.
- Ensure
.envfile contains yourGOOGLE_MAPS_API_KEY. - Refresh Gradle and resolve dependencies.
- Open
MapsServiceApplication.java. - Right-click → Run As > Java Application.
- Runs on
http://localhost:8081(or configured port inapplication.properties).
Ensure this service is running before using the bank-service.