Displaying Attributions

When displaying data from the Places SDK for Android, such as autocomplete results or place name and address, there are some attribution and Google logo requirements you must comply with.

Overview

The attribution and logo requirements fall into the following categories:

The requirements also apply to programmatic Places API calls. If the app has retrieved a place and then shows the data on a follow-up screen without a map, the app must show attributions on the follow-up screen.

Displaying a map

You can display Places API results on a Google Map, or without a map. If you want to display Places API results on a map, then these results must be displayed on a Google Map. It is prohibited to use Places API data on a map that is not a Google map.

Note that you're still required to display any relevant attributions for third-party content.

The 'Powered by Google' attribution

If your application displays data from the Places API on a Google Map, then the Google logo will be included and may not be altered. Applications that display Places API data on the same screen as a Google Map are not required to provide further attribution to Google.

If your application displays Places API data on a page or view without a Google Map, you must show a 'Powered by Google' image with that data. For example, if your application displays a list of places retrieved by the API on one screen, and a Google Map with those places on another screen, the first screen must show the 'Powered by Google' attribution.

The 'Powered by Google' image is included in the AAR in the correct sizes for Android apps. You may not resize or modify these images in any way:

  • For use on a light background: @drawable/places_powered_by_google_light
  • For use on a dark background: @drawable/places_powered_by_google_dark

Attributions for third-party content

Follow these instructions to retrieve third-party attributions, and to display the attributions in your app.

Retrieving attributions from a Place

If your app displays information obtained by calling get place by ID, the app must also display third-party attributions for the place details obtained.

The API returns a Place. To retrieve attributions from the Place, call Place.getAttributions(). The method returns a String, or a blank string if there are no attributions to display.

String placeId = "INSERT_PLACE_ID_HERE";
List<Place.Field> placeFields = Arrays.asList(Place.Field.ID, Place.Field.NAME);
FetchPlaceRequest request = FetchPlaceRequest.builder(placeId, placeFields).build();

placesClient.fetchPlace(request).addOnSuccessListener((response) -> {
    Place place = response.getPlace();
    textView.append("Place found: " + place.getName());
    textView.append("Attributions: " + place.getAttributions());
}).addOnFailureListener((exception) -> {
    if (exception instanceof ApiException) {
        // Handle the error.
    }
});

Displaying attributions for a photo

If your app displays photos, you must show attributions for each photo that has them. To get attributions for a photo, call PhotoMetadata.getAttributions(). The method returns an HTML character sequence, or an empty string if there are no attributions to display.

// Get the photo metadata from the Place object.
PhotoMetadata photoMetadata = place.getPhotoMetadatas().get(0);

// Get the attribution text.
String attributions = photoMetadata.getAttributions();

Displaying third-party attributions

Attributions to third-party providers contain content in HTML format that you must display to the user in the format in which they are provided. Any links included in the HTML must be preserved. We recommend that your app shows this information below the place details.

The API generates attributions for all the places that are used by the app. The attributions are supplied per API call, not per place.

One way to display the attributions is with a TextView. For example:

TextView attributionsText = (TextView) findViewById(R.id.attributions);
String thirdPartyAttributions = place.getAttributions();
attributionsText.setText(thirdPartyAttributions);

Example of a third-party attribution

Listings by <a href="https://www.example.com/">Example Company</a>

Kirim masukan tentang...

Places SDK for Android