Welcome to the Jose Madrid Salsa developer docs — explore features, APIs, and deployment guides.
Jose Madrid SalsaJMS Docs

Store Locator

Store locator feature combining Google Maps, Geocoding, and the locations database

Store Locator

The Store Locator feature at /find-us helps customers discover retail locations that carry Jose Madrid Salsa products. It combines the locations database with Google Maps, Geocoding API, and the Places API to provide an interactive map-based search experience.

Architecture

/find-us page (Server Component)
  -> Query locations from Prisma database
  -> Pass to LocationsMap client component
      -> Geocode addresses without coordinates
      -> Render Google Map with markers
      -> Info windows with business details

The feature integrates three Google APIs:

  • Maps JavaScript API -- Renders the interactive map
  • Geocoding API -- Converts addresses to lat/lng coordinates
  • Places API -- Enriches location data with photos and business details

Components

LocationsMap

File: app/(public)/find-us/_components/LocationsMap.tsx

The main client component that renders the map. See Google Maps Integration for full details on the map implementation.

Key behaviors:

  • Locations with stored coordinates (latitude/longitude) are used directly
  • Locations without coordinates are geocoded in batches (10 at a time, 200ms between batches)
  • Markers display city abbreviations with business name disambiguation
  • Info windows show address, phone, website, and distance (when proximity search is active)

Location Data

Locations are stored in the Prisma database with these relevant fields:

FieldTypeDescription
idStringUnique identifier
businessNameStringStore/business name
addressStringStreet address
cityStringCity name
stateStringState code
zipCodeString?ZIP code
phoneString?Phone number
websiteString?Website URL
latitudeFloat?Pre-geocoded latitude
longitudeFloat?Pre-geocoded longitude

Location Enrichment

When locations are imported or updated, the platform can enrich them with Google Places data:

  1. findPlaceByNameAddress() searches for the business on Google Places
  2. getBestPhotoUrlForPlace() selects the highest quality photo
  3. getCompanyLogoFromWebsite() fetches a logo via Clearbit or Google Favicons

See Google Places Integration for details on the Places API usage.

Environment Variables

The store locator requires these variables (shared with Google Maps and Places):

VariableDescriptionRequired
NEXT_PUBLIC_GOOGLE_MAPS_API_KEYClient-side Maps API keyYes
GOOGLE_PLACES_API_KEYServer-side Places API keyFor enrichment

Distance Calculation

When a user's location is available (via browser geolocation or manual entry), the map displays distance in miles on each info window. The distanceMiles field is calculated on the client side from the user's coordinates to each location's coordinates.

Key Files

FilePurpose
app/(public)/find-us/_components/LocationsMap.tsxMap component
lib/google-places.tsPlaces API helpers for enrichment
lib/locations/query.tsLocation database queries
app/api/locations/Locations API endpoints
app/api/places/Places API proxy endpoint

How is this guide?

Edit on GitHub

Last updated on

On this page