I have a CartoDB.js-App where I load my vis using cartodb.createVis
(I do not manually define Leaflet layers).
How can I reduce the opacity of the Google Maps base layer? I tried the following, as Google Maps has the layer index 0.
var initializeMap = function() {
// map initialization
cartodb.createVis('map', VIZAPI, {
shareable: false,
title: false,
description: false,
search: true,
tiles_loader: false,
center_lat: 47,
center_lon: 8,
zoom: 9,
cartodb_logo: false
})
.done(function(vis, layers) {
// layer 0 is the base layer, layer 1 is cartodb layer
// setInteraction is disabled by default
window.layers = layers;
layers[1].setInteraction(true);
// layers[1] is "all"
layers[1].on('featureOver', function(e, pos, latlng, data) {
updateClubInfo(data.cartodb_id);
});
layers[1].on('featureClick', function(e, pos, latlng, data) {
updateClubInfo(data.cartodb_id);
});
layers[0].setOpacity(0.3);
// layers[1].getSubLayer(0).setCartoCSS()
window.overlays = vis.getOverlays();
})
.error(function(err) {
console.log(err);
});
};
This doesn't work as setOpacity
is not defined on the Google Maps layer.
I also came up with the idea of creating a white, "empty" sublayer between my data layer and the Google Maps layer and set its opacity. But I don't know how to do that with the CartoDB API.