0

I'm a beginner with cartodb. Can I overlap layers with cartodb maps from different user accounts? I mean, I've tried this code and doesn't work, from Rolling Stones Case Study. First, add 'saleiva' user basemap, and then, my other tables, user 'carmenamaya'

var baseLayerDef = {
   sql: "SELECT * FROM rolling_basemap",
   cartocss: "#rolling_basemap { polygon-fill:#333333; polygon-opacity: 0.7; line-opacity:1; line-color: #000; line-width: .3; [feature='Urban Area']{ polygon-fill:#000; polygon-opacity:0; line-width: 0; } }"
};

cartodb.createLayer(map, {
  user_name: 'saleiva',
  type: 'cartodb',
  sublayers: [
    baseLayerDef,
 //   pointsLayerDef,
 //   linesLayerDef
  ]
}).on('done', function(layer) {
   layer created, add it to the map
  map.addLayer(layer);

var pointsLayerDef = {
  sql: "SELECT *, date as date_proc, ST_asGeoJson(the_geom) as geom FROM carmen_amaya",
  cartocss: "#carmen_amaya::oth { marker-fill: #000; marker-opacity: .3; marker-width: 17; marker-allow-overlap: true; } #carmen_amaya { marker-fill: #FFF; marker-opacity: 1; marker-width: 5; marker-line-width: 0; marker-placement: point; marker-type: ellipse; marker-allow-overlap: true; }",
  interactivity: 'geom,city,cartodb_id,date_proc'
};

var linesLayerDef = {
  sql: "select * from carmen_amaya_concerts",
  cartocss: "#carmen_amaya_concerts{ line-width: 1; line-color: #FFF; line-opacity: 0.8; }",
};

cartodb.createLayer(map, {
  user_name: 'carmenamaya',
  type: 'cartodb',
  sublayers: [
//        baseLayerDef,     
    pointsLayerDef,
    linesLayerDef
  ]
}).on('done', function(layer) {
  //     layer created, add it to the map
      map.addLayer(layer);
4
  • What is it that you want to do? Where does the problem occur? Any error messages that you can include? Could you also add any other relevant info that could help solving your problem?
    – Martin
    Commented Feb 4, 2014 at 15:47
  • Nothing appears. The problem is that I am a completely beginner and wanted to copy/use a basemap geojson form The Rolling Stone Case Study which is 12Mb and my free user account doesn't alllow it. That's why I decided to overlap one layer from a map of another user.
    – Montse
    Commented Feb 5, 2014 at 16:23
  • Done it! Yes we can! We can overlap map layers from differents users, using embedded sql cartodb.createLayer(map, { user_name: 'username', type: 'cartodb', sublayers: [ { sql: "SELECT * FROM table", cartocss: "#css { polygon-fill:#333333; polygon-opacity: 0.7; line-opacity:1; line-color: #000; line-width: .3; [feature='Urban Area']{ polygon-fill:#000; polygon-opacity:0; line-width: 0; } }" }]
    – Montse
    Commented Feb 5, 2014 at 17:03
  • 1
    You should probably add that as an answer so this question will appear to be answered. But also, add a link to the case study so other people can see what you're talking about.
    – Amanda
    Commented Feb 5, 2014 at 21:17

1 Answer 1

1

Yes, it is possible to overlap layers from different user accounts, just using embedded sql connections: cartodb.createLayer(map, { user_name: 'username', type: 'cartodb', sublayers: [ { sql: "SELECT * FROM table", cartocss: "#css { polygon-fill:#333333; polygon-opacity: 0.7; line- opacity:1; line-color: #000; line-width: .3; [feature='Urban Area']{ polygon-fill:#000; polygon-opacity:0; line-width: 0; } }" } ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.