Last active
April 5, 2016 14:11
-
-
Save ramiroaznar/8bb76b1bceb6d2c64ad333798d9662fc to your computer and use it in GitHub Desktop.
Points to Line with a fake cartodb_id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Points to Line with fake cartodb_id</title> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | |
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" /> | |
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" /> | |
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script> | |
<style> | |
html, body,#map { | |
width:100%; | |
height:100%; | |
padding: 0; | |
margin: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div id='map'></div> | |
<script type="text/javascript"> | |
function main() { | |
// set center and zoom level | |
var options = { | |
center: [59.5,-151.25], | |
zoom: 10, | |
}; | |
// declare a map object | |
var map = new L.Map('map', options); | |
// add basemap | |
L.tileLayer('http://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', { | |
attribution: 'OpenStreetMaps' | |
}).addTo(map); | |
// add layer | |
cartodb.createLayer(map,{ | |
user_name: 'ramirocartodb', | |
type: 'cartodb', | |
sublayers: [ | |
{ // create fake cartodb_id | |
sql: 'SELECT ST_MakeLine(the_geom_webmercator ORDER BY track_seg_id ASC) AS the_geom_webmercator,track_fid,row_number() OVER() AS cartodb_id FROM ramirocartodb.kachemakbaysp_track_points GROUP BY track_fid', | |
cartocss: '#kachemakbaysp_track_points{line-color: #D6301D;line-width: 5;line-opacity: 0.5;}' | |
} | |
]}).addTo(map) | |
} | |
window.onload = main; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment