I have a carto-map that consists of four layers. The users of my map should have the option to choose the map projection. For one layer this works fine:
$('#selectProjection').on('click', function() {
var srid = $(this).val();
firstLayer.setSQL("SELECT cartodb_id, st_transform(the_geom, " + srid + ") as the_geom_webmercator FROM firsttable");
});
But i have to project all four layers. If a add the same query just for another layer, there is no layer projected at all. This code doesn't work:
$('#selectProjection').on('click', function() {
var srid = $(this).val();
firstLayer.setSQL("SELECT cartodb_id, st_transform(the_geom, " + srid + ") as the_geom_webmercator FROM firsttable");
secondLayer.setSQL("SELECT cartodb_id, st_transform(the_geom, " + srid + ") as the_geom_webmercator FROM secondtable");
});
Does anoyone have an idea?
EDIT: a js fiddle with the whole code: https://jsfiddle.net/nmrs11kq/11/