Created
November 20, 2015 21:55
-
-
Save chriswhong/a4d1e6305ecaf2ad507a to your computer and use it in GitHub Desktop.
Use cartodb.js to add a torque layer from a named map with auth_tokens enabled
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
var layerSource = { | |
type: "torque", | |
options: { | |
auth_token: '{yourAuthToken}', | |
user_name: "{yourCartoDBUsername}", | |
tile_style:"{torqueCartoCSS}", | |
named_map: { | |
name: "{namedmap}" | |
} | |
} | |
} | |
cartodb.createLayer(map, layerSource).done(function(layer) { | |
map.addLayer(layer); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
layer.setAuthToken() doesn't work for torque named maps, auth_token must be added to the options
The trick is that the tile_style, or CartoCSS must be defined in the layerSource definition
A viz.json for a torque layer will include the same layerSource including tile_style