Skip to content

Instantly share code, notes, and snippets.

@ramiroaznar
Created July 29, 2016 12:14
Show Gist options
  • Save ramiroaznar/71634140f2471e9a1804fe70798624e0 to your computer and use it in GitHub Desktop.
Save ramiroaznar/71634140f2471e9a1804fe70798624e0 to your computer and use it in GitHub Desktop.
Routing Query & Styles with CARTO's Location Data Services API
SELECT
1 as cartodb_id, length, shape as the_geom, 'Madrid' as origin
FROM
cdb_route_point_to_point(
cdb_geocode_namedplace_point('Madrid', 'Spain'),
cdb_geocode_namedplace_point('Rome', 'Italy'),
'car')
UNION ALL
SELECT
2 as cartodb_id, length, shape as the_geom, 'Paris' as origin
FROM
cdb_route_point_to_point(
cdb_geocode_namedplace_point('Paris', 'France'),
cdb_geocode_namedplace_point('Rome', 'Italy'),
'car')
UNION ALL
SELECT
3 as cartodb_id, length, shape as the_geom, 'Berlin' as origin
FROM
cdb_route_point_to_point(
cdb_geocode_namedplace_point('Berlin', 'Germany'),
cdb_geocode_namedplace_point('Rome', 'Italy'),
'car')
UNION ALL
SELECT
4 as cartodb_id, length, shape as the_geom, 'Athens' as origin
FROM
cdb_route_point_to_point(
cdb_geocode_namedplace_point('Athens', 'Greece'),
cdb_geocode_namedplace_point('Rome', 'Italy'),
'car')
#route {line-color: red; line-width: 2;line-opacity: 0.7;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment