Overview

Custom maps

Use a custom style

Image, terrain, and vector layers now come with default styles. These are default sources which provide an easy way to access Mapbox's rich data. You can select one of the generic Mapbox styles, or select Custom to use a custom style. For a walkthrough on how to configure a custom style, follow the Custom maps style for Unity tutorial.

For image layers, select Custom to use a custom style from Mapbox Studio.

There are two ways to specify a custom style:

  • Copy a style URL from your Mapbox Studio account and paste it into the Id field of your image factory.
  • Search for a style linked to your account.

    • Note: To search for a style, you may have to generate a new access token with styles:list scope enabled. If you had to create a new access token, remember to swap it out with the old token in your Mapbox Setup panel.

After specifying a custom style, the map will render the new style when you play the scene. You can further customize your map style in Mapbox Studio. Note that there may be some differences in color quality and resolution between Mapbox Studio and Unity: this is expected.

"Mapbox Streets With Building IDs" combines Mapbox-Streets-v7 vector data with our experimental 3D buildings data, which assigns unique IDs to building features to avoid visual artifacts for buildings at tile borders.

Use custom data

You can use your own data with a custom tileset using the Maps SDK for Mapbox Unity. To do so, you'll need to first create a dataset and export it to a tileset using Mapbox Studio.

For example: This custom population density tileset contains a layer outgeojson, which contains the properties id, p, and pkm2. The tileset contains the population per square kilometer in the property (pkm2) for all areas of the United States. You can configure your AbstractMap component in the following way to render extrusions of various blocks of a city and visualize that data on a map.

  1. Right click MAP LAYERS on the AbstractMap component.
  2. Select Custom for the Data Source
  3. Enter peterqliu.d0vin3el in the Map Id field. Note that you can specify the Map Id of any tileset in this field.
  4. Click Add Visualizer to create a new visualizer. Next, name it by clicking Untitled once, specifying a title and pressing Enter. PopulationDensity is used for this example, but you can name this whatever you want.
  5. In the Vector Layer Visualizer settings, set the Primitive Type to Polygon.
  6. Enter outgeojson for the Layer Name. This must match the Layer details for the specified tileset. For this tileset, it is outgeojson.
  7. Set the Extrusion Type to Property Height.
  8. Enter pkm2 for the Property Name. This value must equal the name of a property on the specified tileset. For this tileset, it is pkm2.
  9. Change the Texturing Style to Custom, and add a material of your choice to the Top Material and Side Material fields. Note that the PopulationMat material file is what produces the gradient style seen below. It is from custom code that uses the pkm2 value to style the blocks differently. It is not included in the Maps SDK for Unity.

Here’s the output of that configuration when you play the scene. The screenshot below shows the population density of different blocks in San Francisco.