Skip to content

Instantly share code, notes, and snippets.

@ramiroaznar
Created September 6, 2016 10:49
Show Gist options
  • Save ramiroaznar/1bf2b19add866cf5b3f995abdefa43d1 to your computer and use it in GitHub Desktop.
Save ramiroaznar/1bf2b19add866cf5b3f995abdefa43d1 to your computer and use it in GitHub Desktop.
Named map template for a routing static map
{
"auth": {
"method": "open"
},
"version": "0.0.1",
"name": "teradata_uk",
"placeholders": {
"postcode1": {
"type": "sql_ident",
"default": "M40"
},
"postcode2": {
"type": "sql_ident",
"default": "WC2N"
}
},
"layergroup": {
"version": "1.0.1",
"layers": [
{
"type": "http",
"options": {
"urlTemplate": "http://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png",
"subdomains": "abcd"
}
},
{
"type": "cartodb",
"options": {
"sql": "WITH point1 as (SELECT cdb_geocode_postalcode_point(<%= postcode1 %>, 'UK') as geo ), point2 as (SELECT cdb_geocode_postalcode_point(<%= postcode2 %>, 'UK') as geo ), route AS (SELECT r.shape as geo, r.length FROM point1, point2, cdb_route_point_to_point(point1.geo, point2.geo, 'car') r ) SELECT 3 as cartodb_id, ST_Transform(geo,3857) as the_geom_webmercator, to_char(length::real, '999,999 km') as label FROM route UNION ALL SELECT 1 as cartodb_id, ST_Transform(geo,3857) as the_geom_webmercator, 'From ' || <%= postcode1 %> as label FROM point1 UNION ALL SELECT 2 as cartodb_id, ST_Transform(geo,3857) as the_geom_webmercator, 'To ' || <%= postcode2 %> as label FROM point2 ",
"layer_name": "route",
"cartocss": "#layer['mapnik::geometry_type'=1] {marker-width: 15; marker-fill: #FFB927; marker-fill-opacity: 0.9; marker-line-color: #ffda8d; marker-line-width: 1.5; marker-line-opacity: 1; marker-placement: point; marker-type: ellipse; marker-allow-overlap: true; } #layer['mapnik::geometry_type'=2] {line-width: 9; line-color: #3EBCAE; line-opacity: .7; } #layer::labels {text-name: [label]; text-face-name: 'DejaVu Sans Book'; text-size: 15; text-fill: #343A40; text-label-position-tolerance: 0; text-halo-radius: 1; text-halo-fill: #FFFFFF; text-dy: -10; text-allow-overlap: true; text-placement: point; text-placement-type: dummy; } ",
"cartocss_version": "2.1.1",
"interactivity": [
"cartodb_id",
"name"
],
"table_name": "route",
"attributes": {}
}
}
]
},
"view": {
"zoom": 6,
"center": {
"lng": -3.6,
"lat": 54.97
},
"bounds": {
"west" : -10.17,
"south": 49.92,
"east" : 2.90,
"north": 59.47
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment