Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk3 min

How to Search for Nearby Places by Coordinates in JavaScript

Use Google’s Place.searchNearby() with a coordinate-centered restriction, selected fields, and optional category and ranking filters. Geolocation is a separate input step.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To find places near a latitude and longitude in JavaScript, send those coordinates as the center of a nearby-place search, define the search area, and request only the place data your interface needs. With Google Maps JavaScript, the current Places API flow is Place.searchNearby(); browser geolocation is a separate step needed only when your app must obtain the visitor’s current position.

Nearby search or reverse geocoding?

Choose a nearby search when the question is “What places are around this point?” It returns points of interest, such as restaurants or parks, within a defined area. Reverse geocoding answers a different question: “What address or place name corresponds to these coordinates?” Mapbox describes reverse geocoding as converting coordinates into address or place text, and its Search Box API supports POI search and coordinate reverse lookup. Mapbox Search documentation

As an Amazon Associate I earn from qualifying purchases.

If you already have latitude and longitude and need nearby categorized places for a map, Google Maps JavaScript provides a direct route through the Places library. Mapbox is another option for applications already using its search and geocoding stack. The right choice depends on required categories and fields, ranking, geographic coverage, map compatibility, billing, and regional terms; the available documentation does not establish one provider as universally best.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Search nearby places with Google Maps JavaScript

Enable Places API (New) in the Google Cloud project used by your Maps JavaScript application, load the Places library, then call Place.searchNearby(). The request needs a location restriction centered on the coordinate, a field list, and any filters or ranking preference the feature requires. Google’s example requests display name, location, formatted address, and Google Maps URI; request only fields your interface uses. Google Maps JavaScript Nearby Search

#1 Best Overall
Sale
Garmin Drive™ 53 GPS Navigator
  • Bright, high-resolution 5” glass capacitive touchscreen display lets you easily view your route
  • Get more situational awareness with alerts for school zones, speed changes, sharp curves and more
  • View food, fuel and rest areas along your active route, and see upcoming cities and milestones
  • View Tripadvisor traveler ratings for top-rated restaurants, hotels and attractions to help you make the most of road trips
  • Directory of U.S. national parks simplifies navigation to entrances, visitor centers and landmarks within the parks
const { Place } = await google.maps.importLibrary("places");

const request = {
  fields: ["displayName", "location", "formattedAddress", "googleMapsURI"],
  locationRestriction: {
    center: { lat: 37.7749, lng: -122.4194 },
    radius: 1500
  },
  includedPrimaryTypes: ["restaurant"],
  rankPreference: "DISTANCE"
};

const { places } = await Place.searchNearby(request);

Replace the sample center and radius with your application’s values. Add includedPrimaryTypes only when the feature should constrain results to a category; use a supported primary type for the API. Set ranking to distance when the closest results matter most, or popularity when prominence is more useful. Google’s JavaScript example also shows deriving a radius from map bounds and capping it at 50,000 meters.

The returned place objects can be used to create map markers or populate a list. Handle an empty result set and request failures in the same way you handle other network-dependent UI states; do not assume every coordinate or category will return a result.

Rank #2
Sale
Garmin DriveSmart 66, 6-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
  • 6” high-resolution navigator includes map updates of North America
  • Hands-free calling when paired with your compatible smartphone with BLUETOOTH technology and convenient Garmin voice assist lets you ask for directions to places you want to go
  • Road trip–ready features include the HISTORY database of notable sites, a U.S. national parks directory, Tripadvisor traveler ratings and millions of Foursquare POIs
  • Driver alerts for things such as school zones, sharp curves and speed changes help encourage safer driving and increase situational awareness
  • Access live traffic, fuel prices, parking, weather and smart notifications when you pair this navigator with your compatible smartphone running the Garmin Drive app

Use the Places API web service instead

If your application calls Google’s Places API (New) web service rather than the Maps JavaScript library, send an HTTP POST to https://places.googleapis.com/v1/places:searchNearby. Put the search center and radius in locationRestriction.circle, provide the API key, and include an X-Goog-FieldMask header listing the response fields.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
POST https://places.googleapis.com/v1/places:searchNearby
X-Goog-Api-Key: YOUR_API_KEY
X-Goog-FieldMask: places.displayName,places.location,places.formattedAddress
Content-Type: application/json

{
  "locationRestriction": {
    "circle": {
      "center": { "latitude": 37.7749, "longitude": -122.4194 },
      "radius": 1500
    }
  },
  "includedPrimaryTypes": ["restaurant"],
  "rankPreference": "DISTANCE"
}

For this web-service endpoint, the radius must be greater than zero and no more than 50,000 meters. Google requires a field mask: a request without one returns an error. Field masks also let you avoid requesting unneeded data; Google notes that requested fields affect processing and billing, with different fields associated with different SKU groupings. Check the current field and billing documentation before choosing a mask. Google Places API Nearby Search

Rank #3
Garmin 010-02256-00 eTrex 22x, Rugged Handheld GPS Navigator, Black/Navy
  • Explore confidently with the reliable handheld GPS
  • 2.2” sunlight-readable color display with 240 x 320 display pixels for improved readability
  • Preloaded with Topo Active maps with routable roads and trails for cycling and hiking
  • Support for GPS and GLONASS satellite systems allows for tracking in more challenging environments than GPS alone
  • 8 GB of internal memory for map downloads plus a micro SD card slot
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Get coordinates from the browser only when needed

If the feature searches around the visitor, obtain the current coordinates using browser geolocation, then pass latitude and longitude to the nearby-search request. If coordinates are already supplied by the user or application data, skip geolocation. It is not part of the place search itself. The W3C Geolocation specification is the standards reference for browser device location. W3C Geolocation

Because geolocation obtains device location, design the feature so the user can understand why it is requested and what the app will do with the result. Keep the search function independent: it should accept a coordinate regardless of whether it came from geolocation, a saved location, or another input.

Quick Recap

SaleBestseller No. 1
Garmin Drive™ 53 GPS Navigator
Garmin Drive™ 53 GPS Navigator
Includes detailed map updates of the North America
$141.98
SaleBestseller No. 2
Garmin DriveSmart 66, 6-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
Garmin DriveSmart 66, 6-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
6” high-resolution navigator includes map updates of North America; Built-in Wi-Fi connectivity allows easy map and software updates without a computer
$187.48
Bestseller No. 3
Garmin 010-02256-00 eTrex 22x, Rugged Handheld GPS Navigator, Black/Navy
Garmin 010-02256-00 eTrex 22x, Rugged Handheld GPS Navigator, Black/Navy
Explore confidently with the reliable handheld GPS; Preloaded with Topo Active maps with routable roads and trails for cycling and hiking
$199.99
SaleBestseller No. 4
Garmin DriveSmart 86, 8-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
Garmin DriveSmart 86, 8-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
Built-in Wi-Fi connectivity allows easy map and software updates without a computer
$281.76
Best Value
Sale
Garmin Drive™ 53 GPS Navigator, High-Resolution Touchscreen, Simple On-Screen Menus and Easy-to-See Maps, Driver Alerts (Renewed)
  • Bright, high-resolution 5” glass capacitive touchscreen display lets you easily view your route
  • Get more situational awareness with alerts for school zones, speed changes, sharp curves and more
  • View food, fuel and rest areas along your active route, and see upcoming cities and milestones
  • View Tripadvisor traveler ratings for top-rated restaurants, hotels and attractions to help you make the most of road trips
  • Directory of U.S. national parks simplifies navigation to entrances, visitor centers and landmarks within the parks
Rank #4
Sale
Garmin DriveSmart 86, 8-inch Car GPS Navigator with Bright, Crisp High-Resolution Maps and Garmin Voice Assist
  • 8” navigator with high-resolution, dual-orientation display and map updates of North America .Special Feature:Large Display; Voice Assist; Hands-Free Calling; Live Traffic and Weather; Traffic Cams and Parking; Smart Notifications,Driver Alerts; Tripadvisor; National Parks Directory; Find Places by Name; Garmin Real Directions Feature.
  • Hands-free calling when paired with your compatible smartphone with BLUETOOTH technology and convenient Garmin voice assist lets you ask for directions to places you want to go
  • Road trip–ready features include the HISTORY database of notable sites, a U.S. national parks directory, Tripadvisor traveler ratings and millions of Foursquare POIs
  • Driver alerts for things such as school zones, sharp curves and speed changes help encourage safer driving and increase situational awareness
  • Access live traffic, fuel prices, weather, parking and smart notifications when you pair this navigator with your compatible smartphone running the Garmin Drive app

Choose an API around the feature you are building

  • Place categories: confirm the provider supports the categories the interface needs.
  • Returned fields: identify the data used for markers, cards, or navigation, then request only those fields.
  • Ranking: decide whether proximity or prominence better serves the user.
  • Map and search stack: account for compatibility with the mapping and search services already in the application.
  • Geography and terms: verify coverage and applicable regional terms for the places and users involved.
  • Billing: compare the cost implications of the specific fields and request patterns in your project; there is no universal cost winner established by the API documentation.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.