Skip to content

Instantly share code, notes, and snippets.

@rayrayzayzay
Created May 12, 2023 21:58
Show Gist options
  • Save rayrayzayzay/e468d3b863ab63de0f08f9608797d3cc to your computer and use it in GitHub Desktop.
Save rayrayzayzay/e468d3b863ab63de0f08f9608797d3cc to your computer and use it in GitHub Desktop.
function getFullRouteGeometry(coords, viewport) {
const roundedZoom = Math.round(viewport.zoom)
const fromCache = cache.get(roundedZoom).get(coords)
if (fromCache) return clipToViewport(fromCache, viewport);
const simplified = simplify(coords, 1 / roundedZoom)
cache.get(roundedZoom).set(coords, simplified);
return clipToViewport(simplified, viewport);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment