---
title: "Add a custom color background to the globe | JavaScript maps SDK"
description: "Add a custom color background to the globe."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Add a custom color background to the globe

Use the `space` option in the map constructor to enable a simple space background with a solid color.

This option **only takes effect** when used in conjunction with the `projection: 'globe'` parameter.

### NPM module setup

```bash
npm install --save @maptiler/sdk
```

#### main.js

```js
import { Map, MapStyle, config } from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';

config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
const map = new Map({
  container: 'map', // container's id or the HTML element in which the SDK will render the map
  style: MapStyle.OUTDOOR,
  projection: "globe",
  space: {
    color: '#111122'
  }
});
```

#### index.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="robots" content="noindex">
  <title>Add a custom color background to the globe | NPM example</title>
  <link rel="stylesheet" href="./style.css">
</head>
<body>
  <div id="map"></div>
  <script type="module" src="./main.js"></script>
</body>
</html>
```

#### style.css

```css
body {
  margin: 0;
  padding: 0;
}

#map {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
}
```

### Basic JavaScript setup

```html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <title>Globe with space background</title>
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
  <script src="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.umd.min.js"></script>
  <link href="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.css" rel="stylesheet" />
  <style>
    body {
      margin: 0;
      padding: 0;
    }

    #map {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 100%;
    }
  </style>
</head>

<body>
  <div id="map"></div>
  <script>
    maptilersdk.config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
    const map = new maptilersdk.Map({
      container: 'map', // container's id or the HTML element in which the SDK will render the map
      style: maptilersdk.MapStyle.OUTDOOR,
      projection: "globe",
      space: {
        color: '#111122'
      }
    });
  </script>
</body>

</html>
```

## Learn more

For space customization and options, check the [CubemapLayerConstructorOptions](https://docs.maptiler.com/sdk-js/api/types/#CubemapLayerConstructorOptions).

## Related examples

### [Globe with custom halo](https://docs.maptiler.com/sdk-js/examples/halo-custom/)

Examples

Add a custom atmospheric glow effect around your globe.

### [Globe with initial space background](https://docs.maptiler.com/sdk-js/examples/space-simple/)

Examples

Add a deep space background environment to the globe.

### [Globe with milkyway and stars](https://docs.maptiler.com/sdk-js/examples/space-milkyway/)

Examples

Add a milkyway and stars background to the globe.

### [Add a 3D model to globe using MapTiler 3D JS](https://docs.maptiler.com/sdk-js/examples/globe-3d-model/)

Examples

Integrate 3D models into your interactive globe map surface.
