Skip to content

Instantly share code, notes, and snippets.

<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v1.3.0/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet/v1.3.0/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
</head>
<body>
<div id="map" style="height: 100%;"></div>
<script>
Error: Parse error on line 3514:
...": [] } ]}Request When a Route
-----------------^
Expecting 'EOF', '}', ',', ']'
{
"results": [
{
"search_id": "arrival search example",
"locations": [
{
"results": [
{
"search_id": "arrival search example",
"locations": [
{
"id": "Hyde Park",
"properties": [
{
"travel_time": 1499,
"locations": [
{
"id": "London center",
"coords": {
"lat": 51.508930,
"lng": -0.131387
}
},
{
"id": "Hyde Park",
@LouisaKB
LouisaKB / Request
Created October 23, 2018 12:49
Request
POST /v4/routes HTTP/1.1
Host: api.traveltimeapp.com
Content-Type: application/json
Accept: application/json
X-Application-Id: ...
X-Api-Key: ...
{
"locations": [
{
{
"results": [
{
"search_id": "7f45bc64-b567-4453-9477-50d4ce928690",
"shapes": [
{
"shell": [
{
"lat": 51.51180324,
"lng": -0.17239974000000036
import json
def remap_linear_ring(linear_ring):
return list(map(lambda c: [c['lng'], c['lat']], linear_ring))
def shapes_to_multipolygon(shapes):
allRings = []
for shape in shapes:
shell = remap_linear_ring(shape['shell'])
holes = list(map(lambda h:remap_linear_ring(h), shape['holes']))
The complete code for reference:
function remapLinearRing(linearRing) {
return linearRing.map(c => [c['lng'], c['lat']]);
}
function shapesToMultiPolygon(shapes) {
var allRings = shapes.map(function (shape) {
var shell = remapLinearRing(shape['shell']);
var holes = shape['holes'].map(h => remapLinearRing(h));