I have an issue with createLayer. The date has duplicate polygons ( countries) so I ha have included a SQL to group and sum up the the values of those duplicated countries :

cartodb.createLayer(map, { user_name: 'migrantreport', type: 'cartodb', sublayers: [{ sql: "SELECT country, SUM(dec_16)dec_16 FROM origins_by_country_of_arrival_sp_copy GROUP BY country",

cartocss: "#origins_by_country_of_arrival_sp_copy{polygon-fill: #FFFFB2; polygon-opacity: 0.8;line-color: #FFF;line-width: 0.5;line-opacity: 1;}", }] }).addTo(map)

The SQL query works ( I already test it externally ) but when using the code above it doesn't work nor gives any error...

I could group all the polygons beforehand but I need to keep it like this to perform different queries later where the data needs to be non grouped ..

any suggestion??

1 Answer 1


In order to make createLayer work, you need to add to your query at least the_geom_webmercator field. I would also recommend adding the cartodb_id and the_geom columns. Your query works but you need the the_geom_webmercator to "paint" the geometries of your dataset/layer on the map.

  • Thanks Ramiro, I've got it :-) working perfectly . Super helpful. Mar 1, 2017 at 21:13

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.