I have two tables in CartoDB, one is a fixed layer with locations of restaurants in a city. The other layer has data about the locations where police had to go because of fights for example (say 112 calls) that happened in the city during a one year period.
Because I want to create my own basemap I have been using the createLayer
function in CartoDB.js to display the restaurants. This works fine. But next I want to add a Torque map of the 112 calls on top of this. However, when I do finally get the Torque map to work, the other layer of the restaurants is no longer visible.
What should I do to make both layers visible?
Below a short version of the code I am using now, which only shows the Torque layer (also, in this version there is no time slider visible, which I hope will become visible once I get both layers working):
// initiate leaflet map
map = new L.Map('map', {
center: [0,0],
zoom: 11
})
// load the base map
L.tileLayer(mapURL, {
attribution: '...'
}).addTo(map);
var CARTOCSS_TORQUE = {...};
var torqueLayer = new L.TorqueLayer({
user : 'username',
table : 'table_name',
column : 'column',
countby : 'count(cartodb_id)',
resolution : 2,
steps : 300,
blendmode : 'multiply',
animationDuration: 90,
map: map,
cartocss : CARTOCSS_TORQUE
});
cartodb.createLayer(map, layerURL)
.addTo(map)
.done(function(layer) {
...make a small SQL query change...
})
.on('error', function(err) {
console.log(err);
});
torqueLayer.addTo(map);
torqueLayer.play();