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


npm install --save @maptiler/sdk
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
  });
});

Learn more

For space customization and options, check the CubemapLayerConstructorOptions.

Add a custom halo around the globe

Globe with custom halo

Examples

Add a custom atmospheric glow effect around your globe.

Add a start space background to the globe

Globe with initial space background

Examples

Add a deep space background environment to the globe.

Add a milkyway and stars background to the globe

Globe with milkyway and stars

Examples

Add a milkyway and stars background to the globe.

Projection control how to toggle the map between mercator and globe projection

Projection control (globe)

Tutorials

Toggle between Mercator and globe projections using map controls.

Was this helpful?