Skip to content

Instantly share code, notes, and snippets.

@TravelTime-Frontend
Created February 21, 2023 08:13
Show Gist options
  • Save TravelTime-Frontend/b81cd57cf24f8805ac4238c7d5fd564f to your computer and use it in GitHub Desktop.
Save TravelTime-Frontend/b81cd57cf24f8805ac4238c7d5fd564f to your computer and use it in GitHub Desktop.
function drawTimeMap(map, response) {
// Reference for the response: http://docs.traveltimeplatform.com/reference/time-map/#response-body-json-attributes
var shapesCoords = response.results[0].shapes.map(function (polygon) {
var shell = ringCoordsHashToArray(polygon.shell);
var holes = polygon.holes.map(ringCoordsHashToArray);
return [shell].concat(holes);
});
var polygon = L.polygon(shapesCoords, { color: 'red' });
polygon.addTo(map);
map.fitBounds(polygon.getBounds());
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment