I have a function that creating new variable by clicking. I need to store this variables and display after reloading the page.
maptilersdk.config.apiKey = 'FeLE2yBSiMMi7tgevphq';
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.STREETS,
center: [30.5, 50.5], // starting position [lng, lat]
zoom: 14, // starting zoom
});
const marker = new maptilersdk.Marker({
color: '#000',
draggable: true,
})
.setLngLat([30.5, 50.5])
.addTo(map);
**map.on('click', function (e) {
const marker = new maptilersdk.Marker({
color: '#000',
draggable: true,
})
.setLngLat([e.lngLat.lng, e.lngLat.lat])
.addTo(map);
});**
I have tried to create an array and push elements inside. It doesn't work. And the major question is how to display this data after reloading the page.