---
title: "Add a custom milkyway, stars and halo background to the globe | JavaScript maps SDK"
description: "Add a red Milky Way and halo 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 milkyway, stars and halo background to the globe

Customize the map background to create a red Milky Way effect and create a _“toxic”_ halo around the Earth.

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

In this example, we’ll use a Milky Way background, we will change the color of the stars to red and add a custom halo to create a toxic atmosphere effect.

### 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.SATELLITE,
  projection: "globe",
  center: [83, 30.8],
  zoom: 0,
  halo: {
    scale: 1,
    stops: [
      [0.0, "rgba(77,51,15,1)"],
      [0.5, "rgba(255,111,0,0.5)"],
      [0.75, "rgba(250,0,0,0.0)"],
    ],
  },
  space: {
    color: "#ff0000",
    preset: "milkyway-bright",
  }
});

map.on('load', () => {
  map.flyTo({ //zoom out the map so that the background of the stars can be seen better.
    zoom: -1,
    essential: true
  });
});
```

#### index.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="robots" content="noindex">
  <title>Add a custom milkyway, stars and halo 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.SATELLITE,
      projection: "globe",
      center: [83, 30.8],
      zoom: 0,
      halo: {
        scale: 1,
        stops: [
          [0.0, "rgba(77,51,15,1)"],
          [0.5, "rgba(255,111,0,0.5)"],
          [0.75, "rgba(250,0,0,0.0)"],
        ],
      },
      space: {
        color: "#ff0000",
        preset: "milkyway-bright",
      }
    });
    map.on('load', () => {
      map.flyTo({ //zoom out the map so that the background of the stars can be seen better.
        zoom: -1,
        essential: true
      });
    });
  </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.

### [Projection control (globe)](https://docs.maptiler.com/sdk-js/examples/globe-control/)

Tutorials

Toggle between Mercator and globe projections using map controls.
