A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/maps/documentation/places/android-sdk/nearby-search below:

Nearby Search (New) | Places SDK for Android

Skip to main content Nearby Search (New)

Stay organized with collections Save and categorize content based on your preferences.

A Nearby Search (New) request takes as input the region to search specified as a circle, defined by the latitude and longitude coordinates of the center point of the circle and the radius in meters. The request returns a list of matching places, each represented by a Place object, within the specified search area.

By default, the response contains places of all types within the search area. You can optionally filter the response by specifying a list of place types to explicitly include in or exclude from the response. For example, you can specify to include only those places in the response that are of type "restaurant", "bakery", and "cafe", or exclude all places of type "school".

Note: Nearby Search (New) is available in Places SDK for Android version 3.5.0 and later. For more information, see Choose your SDK version. For more information about using the Kotlin APIs added in version 4.0.0, see the Reference Overview. Nearby Search (New) requests

Make a Nearby Search (New) request by calling PlacesClient.searchNearby, passing a SearchNearbyRequest object that defines the request parameters.

The SearchNearbyRequest object specifies all of the required and optional parameters for the request. The required parameters include:

This example nearby search request specifies that the response Place objects contain the place fields Place.Field.ID and Place.Field.DISPLAY_NAME for each Place object in the search results. It also filters the response to only return places of type "restaurant" and "cafe", but exclude places of type "pizza_restaurant" and "american_restaurant".

// Define a list of fields to include in the response for each returned place.
final List<Place.Field> placeFields = Arrays.asList(Place.Field.ID, Place.Field.DISPLAY_NAME);

// Define the search area as a 1000 meter diameter circle in New York, NY.
LatLng center = new LatLng(40.7580, -73.9855);
CircularBounds circle = CircularBounds.newInstance(center, /* radius = */ 1000);

// Define a list of types to include.
final List<String> includedTypes = Arrays.asList("restaurant", "cafe");
// Define a list of types to exclude.
final List<String> excludedTypes = Arrays.asList("pizza_restaurant", "american_restaurant");

// Use the builder to create a SearchNearbyRequest object.
final SearchNearbyRequest searchNearbyRequest =
SearchNearbyRequest.builder(/* location restriction = */ circle, placeFields)
    .setIncludedTypes(includedTypes)
    .setExcludedTypes(excludedTypes)
    .setMaxResultCount(10)
    .build());

// Call placesClient.searchNearby() to perform the search.
// Define a response handler to process the returned List of Place objects.
placesClient.searchNearby(searchNearbyRequest)
    .addOnSuccessListener(response -> {
      List<Place> places = response.getPlaces();
    });
Note: For more information on initializing PlacesClient, see Initialize the Places API client.

You can use a CancellationToken to attempt to cancel a request to any of the request classes (for example, FetchPlaceRequest). Cancellation is done on a best-effort basis. Once a cancellation request is issued, no response will be returned. Issuing a cancellation token does NOT guarantee that a particular request will be cancelled, and you may still be charged for the request even if no response is returned.

Nearby Search (New) responses

The SearchNearbyResponse class represents the response from a search request. A SearchNearbyResponse object contains:

For example, in the request you defined a field list as:

// Define a list of fields to include in the response for each returned place.
final List<Place.Field> placeFields = Arrays.asList(Place.Field.ID, Place.Field.NAME);

This field list means that each Place object in the response contains only the place ID and name of each matching place. You can then use the Place.getId() and Place.getName() methods to access these fields in each Place object.

For more examples of accessing data in a Place object, see Access Place object data fields.

Required parameters

Use the SearchNearbyRequest object to specify the required parameters for the search.

// Define a list of fields to include in the response for each returned place.
final List<Place.Field> placeFields = Arrays.asList(Place.Field.ID, Place.Field.DISPLAY_NAME);
Optional parameters

Use the SearchNearbyRequest object to specify the optional parameters for the search.

Display attributions in your app

When your app displays information obtained from PlacesClient, such as photos and reviews, the app must also display the required attributions.

For more information, see Policies for Places SDK for Android.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-14 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["Nearby Search lets you search for places within a specified radius of a central point, returning a list of matching places."],["You can filter search results by place type, including or excluding specific categories, and limit the maximum number of results."],["Each place result is represented by a `Place` object, containing details like ID, name, and other attributes specified in the request."],["Nearby Search (New) is available in Places SDK for Android version 3.5.0 and later."],["When displaying information from `PlacesClient`, ensure your app displays attributions as required by Google's policies."]]],["Nearby Search (New) allows searching for places within a defined circular region using latitude, longitude, and radius. The search is initiated via `PlacesClient.searchNearby`, with parameters specified in a `SearchNearbyRequest` object, including mandatory fields like location and the desired data fields of a `Place` object. Users can filter results by including/excluding place types. The response, a `SearchNearbyResponse` object, contains a list of `Place` objects, each with specified data. Optional parameters include max results, rank preference, and region code. The data required and optional also have a different rate when being used.\n"]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4