Plugin to add falling snow to your 2GIS MapGL map.
Install with NPM:
npm install mapgl-snow
Then initialize with passing MapGL Map object:
import { load } from '@2gis/mapgl';
import { Snow } from 'mapgl-snow';
load().then((mapgl) => {
// Initialize MapGL map
const map = new mapgl.Map('map', {
center: [82.920412, 55.030111],
zoom: 15,
key: 'YOUR MAPGL API KEY',
});
// Initialize snow
const snow = new Snow(map);
// Change snow options on the fly
snow.setOptions(options);
});
Install in browser:
<html>
<head>
<script src="https://mapgl.2gis.com/api/js/v1"></script>
<script src="https://unpkg.com/mapgl-snow"></script>
<head>
<body>
<div id="map"></div>
<script>
const map = new mapgl.Map('map', {
center: [37.590783, 55.731226],
zoom: 13.48,
key: 'Your API key here',
});
const snow = new mapglSnow.Snow(map);
</script>
</body>
</html>
Snow options have several fields:
minZoom
– the minimum zoom from which the snow will be showncolor
– the color of the snowflakes in RGBA format, e.g.[255, 255, 255, 1]
size
– the size of the snowflakesparticleNumber
– the amount of the snowflakesvelocityX
,velocityY
,velocityZ
– the wind speed in each directiondispersion
– the dispersion of the speed