@trailstash/ultra
Version:
A web based tool for making MapLibre GL maps with data from sources such as Overpass, GeoJSON, GPX, KML, TCX, etc
20 lines (19 loc) • 537 B
JavaScript
const dirs = {
n: "{{north}}",
s: "{{south}}",
e: "{{east}}",
w: "{{west}}",
};
export function setQueryBounds(query, bounds) {
return query
.replace(/{{[wsen]+}}/g, (match) =>
Array.from(match.slice(2, -2))
.map((dir) => dirs[dir])
.join(","),
)
.replace(/{{bbox}}/g, `{{south}},{{west}},{{north}},{{east}}`)
.replace(/{{south}}/g, bounds.getSouth())
.replace(/{{west}}/g, bounds.getWest())
.replace(/{{north}}/g, bounds.getNorth())
.replace(/{{east}}/g, bounds.getEast());
}