Using the Playable Locations API

This section explains how to get playable locations, and it also contains examples that demonstrate how to call the APIs.

Getting playable locations

You retrieve sets of playable locations on-demand, as your players progress through your game. You don't retrieve and then cache a large dataset for use over a long period.

You get a set of playable locations by calling the searchPlayableLocations method. In your call, you specify the area to search within, and your also specify filter criteria. The searchPlayableLocations method returns a set of PlayableLocation objects, which contains both curated playable locations and generated playable locations.

The HTTP request

The following code demonstrates how to call the searchPlayableLocations method by making an HTTP POST request, passing parameters in the request body.

POST https://playablelocations.googleapis.com/v3/searchPlayableLocations&key=YOUR_API_KEY

The request body

When you call the searchPlayableLocations method, you pass the call parameters using a JSON object within the HTTP request body.

{
  "areaFilter": {
    "s2CellId": string,
    "pointExclusions": [
      {
        "point": string,
        "minSpacingMeters": number
      }
    ]
  },
  "criteria": [
    {
      "gameObjectType": number,
      "filter": {
          "maxLocationCount": number,
          "spacing": {
            "minSpacingMeters": number,
            "pointType": enum(PointType)
          },
          "includedTypes": [
            string
          ],
          "excludedTypes": [
            string
          ],
          "contentRating": enum(ContentRating),
          "accessTypes": [
            enum(AccessType)
          ]
      },
      "ranking": {
        "typesProminenceModifier": {
          string: number,
          ...
        },
        "busyness": {
          "busyness": enum(BusynessModifier)
        },
        "capacity": {
          "capacity": enum(CapacityModifier)
        },
        "dwellability": {
          "dwellability": enum(DwellabilityModifier)
        },
        "artisticallyInteresting": {
          "artisticallyInteresting": enum(ArtisticallyInterestingModifier)
        }
      },
      "fieldsToReturn": string
    }
  ]
}

The request object model

The relationships between the JSON sub-objects is depicted in the following illustration.

Request parameters vector graphic

Example 1: request body

The following code example demonstrates filters and fields_to_return.

{
   "area_filter":{
      "s2_cell_id":7715420662885515264
   },
   "criteria":[
      {
         "gameObjectType":1,
         "filter":{
            "maxLocationCount":4,
            "includedTypes":[
               "park"
            ]
         },
         "fields_to_return": {"paths": ["name"]}
      },
      {
         "gameObjectType":2,
         "filter":{
            "maxLocationCount":4,
            "excludedTypes":[
               "park"
            ]
         },
         "fields_to_return": {"paths": ["types", "addresses"]}}
   ]
}

Example 2: request body

The following code example demonstrates maxLocationCount for various object types.

{
   "area_filter":{
      "s2_cell_id":7715420662885515264
   },
   "criteria":[
      {
         "gameObjectType":1,
         "filter":{
            "maxLocationCount":4,
            "spacing":{
               "minSpacingMeters":300
            }
         }
      },
      {
         "gameObjectType":2,
         "filter":{
            "maxLocationCount":4,
            "spacing":{
               "minSpacingMeters":200
            }
         }
      },
      {
         "gameObjectType":3,
         "filter":{
            "maxLocationCount":50,
            "spacing":{
               "minSpacingMeters":50
            }
         }
      }
   ]
}

Send feedback about...

Google Maps Platform gaming solution
Google Maps Platform gaming solution