New pricing changes went into effect on July 16, 2018. For more information, check out the Guide for Existing Users.

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 apply to the place picker UI widget as well as the programmatic API calls. If the app has retrieved a place via the place picker 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 Google Play services library, 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/powered_by_google_light
  • For use on a dark background: @drawable/powered_by_google_dark

The following zip file contains the 'Powered by Google' logo in the correct sizes for desktop, Android and iOS applications. You may not resize or modify these logos in any way.

Download: powered_by_google.zip

Attributions for third-party content

Follow these instructions to retrieve third-party attributions from the place picker or other API calls, and to display the attributions in your app.

Retrieving attributions from the place picker

To retrieve attributions from the place picker, call PlacePicker.getAttributions() passing it the current Intent containing the place the user has selected. The method returns an HTML string, or null if there are no attributions to display.

String thirdPartyAttributions = PlacePicker.getAttributions(intent);
if (thirdPartyAttributions == null) {
  thirdPartyAttributions = "";
}

Retrieving attributions from a PlaceLikelihoodBuffer

If your app displays information obtained by requesting the device's current place, the app must also display third-party attributions for the place details obtained.

The API returns a PlaceLikelihoodBuffer containing a list of likely places. To retrieve attributions from the PlaceLikelihoodBuffer, call PlaceLikelihoodBuffer.getAttributions(). The method returns an HTML character sequence, or null if there are no attributions to display.

PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
    .getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
  @Override
  public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
    final CharSequence thirdPartyAttributions =
        likelyPlaces.getAttributions();
    ...
  }
  likelyPlaces.release();
});

Retrieving attributions from a PlaceBuffer

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 PlaceBuffer containing a list of places. To retrieve attributions from the PlaceBuffer, call PlaceBuffer.getAttributions(). The method returns an HTML character sequence, or null if there are no attributions to display.

Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId)
    .setResultCallback(new ResultCallback<PlaceBuffer>() {
  @Override
  public void onResult(PlaceBuffer places) {
    if (places.getStatus().isSuccess()) {
        ...
        final CharSequence thirdPartyAttributions =
            places.getAttributions();
    }
    places.release();
  }
});

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 PlacePhotoMetadata.getAttributions(). The method returns an HTML character sequence, or null if there are no attributions to display.

Places.GeoDataApi.getPlacePhotos(mGoogleApiClient, placeId)
    .setResultCallback(new ResultCallback<PlacePhotoMetadataResult>() {
  @Override
  public void onResult(PlacePhotoMetadataResult photos) {
    if (photos.getStatus().isSuccess()) {
      // Get attribution for the first photo in the list.
      PlacePhotoMetadataBuffer photoResults = photos.getPhotoMetadata();
      if (photoResults.getCount() > 0) {
        PlacePhotoMetadata photo = photoMetadata.get(0);
        CharSequence attribution = photo.getAttributions();
      }
      photoResults.release();
    }
});

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 = PlacePicker.getAttributions(intent);
if (thirdPartyAttributions == null) {
  thirdPartyAttributions = "";
}
attributionsText.setText(Html.fromHtml(thirdPartyAttributions));

Example of a third-party attribution

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

Оставить отзыв о...

Текущей странице
location_on
Places SDK for Android