Geolocation Meets Local Search: Building 'What's Near Me' Experiences
Users don't think in coordinates. They think in questions: 'Where's the nearest EV charger?', 'Any good restaurants round here?', 'Is there a hotel near the station?' The browser's Geolocation API gives you their position; Goggle Places' Nearby lookup answers the question. Together, they power the 'what's near me' experiences that users love.
Getting the user's position
The browser Geolocation API lets you request a user's latitude and longitude with a single JavaScript call. Best practice: trigger the request only after a user action — tapping 'Find nearby' or 'Use my location' — rather than on page load. Display a brief explanation of why you need their location before the browser prompt appears. This 'pre-prompt' pattern dramatically increases opt-in rates and builds trust from the first interaction.
Feeding coordinates into Nearby
Once you have a lat/lng, pass it straight to Goggle Places' GET /nearby endpoint with a radius and an optional category filter. The API returns points of interest around that position — restaurants, pubs, hotels, EV charging stations, transport stops, and more — sorted by proximity. For map-based UIs, you can also anchor by a bounding box, loading exactly what's visible as the user pans. It's a single authenticated call, and results come back as structured JSON with names, categories, and coordinates ready to drop onto your map.
Handling permission denials gracefully
Users can — and do — deny location access. Your app needs a fallback. The best approach: let them type a place name, town, or postcode into Goggle Places' predictive search, then use the returned coordinates as the centre point for the Nearby lookup. The experience stays seamless: whether the user shares their GPS position or types 'Manchester', they still get a rich list of nearby places.
Showing results on a vector map
A list of nearby places is useful; a list plus a map is powerful. Goggle Places' hosted vector maps render beautifully on any device, with built-in POI layers you can toggle by category. Plot Nearby results as markers on the map, colour-coded by type — blue for hotels, green for EV chargers, red for restaurants. When the user taps a marker, show the place details in a card. When they pan the map, fire a new viewport-based Nearby query to keep the results fresh. This is how you build the kind of interactive local discovery experience that keeps users engaged.
From discovery to directions
Finding a place is only half the journey — the user also needs to get there. Once they've selected a Nearby result, pass their position and the destination to Goggle Places' Directions API to calculate a route by car, bike, foot, or public transport. Display it on the same vector map with turn-by-turn instructions. The entire flow — locate me, show what's nearby, get me there — runs through a single API key, with no additional providers to integrate.
Privacy done right
Location data is sensitive. A raw latitude/longitude pair can identify where someone lives or works. Best practice: use the coordinates to call the Nearby API, display the results, and don't persist the raw position unless your use case genuinely requires it. If you do store coordinates — for order fulfilment, say — encrypt them at rest and delete them once the task is complete. Building with privacy in mind isn't just good ethics; under GDPR and UK data protection law, it's a legal requirement.
Get started with the free tier
Every Goggle Places service — Nearby, Search, Maps, Directions — comes with a free monthly allowance. You can build and test your 'what's near me' feature without entering a credit card. When you're ready to go live, transparent per-request pricing scales with you. One API key, one dashboard, complete GB coverage, and no surprises on the invoice.