@trailstash/ultra
Version:
A web based tool for making MapLibre GL maps with data from sources such as Overpass, GeoJSON, GPX, KML, TCX, etc
32 lines (29 loc) • 624 B
JavaScript
export const localStorage = {
getItem: (key) => {
try {
return JSON.parse(window.localStorage.getItem(key));
} catch {
return null;
}
},
setItem: (key, value) => {
try {
return window.localStorage.setItem(key, JSON.stringify(value));
} catch {
return;
}
},
};
export default localStorage;
export const optionsFromStorage = () => {
const options = {};
const center = localStorage.getItem("mapCenter");
const zoom = localStorage.getItem("mapZoom");
if (center) {
options.center = center;
}
if (zoom) {
options.zoom = zoom;
}
return options;
};