Atmosphere
Enhance your map with atmospheric effects using the Atmosphere component.
Props
Name
Type
Description
Default
Example
import { Component, createSignal } from "solid-js";
import MapGL, { Viewport, Atmosphere } from "solid-map-gl";
import 'mapbox-gl/dist/mapbox-gl.css';
const App: Component = () => {
// Create a state hook for the viewport settings
const [viewport, setViewport] = createSignal({
center: [0, 52], // Longitude, Latitude
zoom: 6, // Zoom level
pitch: 100 // Map pitch in degrees
} as Viewport);
// Define the style for the atmosphere effect
const atmosphereStyle = {
color: 'white', // The color of the fog
horizonBlend: 0.1, // Blend factor of the fog over the horizon line
intensity: 0.5 // The intensity of the fog
};
// Render the map with the Atmosphere component
return (
<MapGL
options={{ style: 'mb:sat_street' }} // Map style URI
viewport={viewport()} // Viewport state
onViewportChange={(newViewport: Viewport) => setViewport(newViewport)} // Handler for viewport changes
>
<Atmosphere style={atmosphereStyle} /> // Atmosphere component with custom style
</MapGL>
);
};Last updated