0

I'm working in Carto.com but I'm still new with this, therefore my question might be somewhat banal. I have tried to generate a map of US with two layers: one layer reffering to the state and the other one for ZIP Codes. The layers change depending on the zoom level - if the zoom level is higher than 5 then you see the zip codes; otherwise you see the states.

I want the pop-up (hover) to be active for both layers, but only when each of them activate. But now the pop-up for the ZIP Code level is also displayed in the state level and vice versa. This means that when I look at the US map by state and hover over it,I get displayed data about the ZIP Codes.

This is the CSS code I've added for the layer change (I worked with the visibility of the layer):

#idToHide[zoom<6] {

  polygon-opacity: 0;
  raster-opacity: 0;
  line-opacity: 0;

}

What should I do to set the pop-ups visibility accordingly to the layer?

1

Changing the opacity properties is not the same as showing/hiding a layer. Have a look at this map. It also contains two layers (countries and cities), both with hover popups activated. Countries are shown in zoom levels less than 5:

enter image description here

While cities are shown in zoom levels equal or greater than 5:

enter image description here

Both popups work within the range of zoom levels in which their layers are shown. Please compare your CartoCSS (next time it would be very useful to post the whole code) with mine. Finally, there is also documentation about zoom based styling in CARTO website.

  • Thank you for your help. It's exactly what I was searching for. – Carmen Apr 12 '17 at 9:42
  • thx ramiro for this solution. is it possible, that the documentation link you posted ist only valid for die old cartoDB? – AndreasK May 5 '17 at 7:39
  • No, it's not. You can still have access to CartoCSS styling. Check this guides about CartoCSS and TurboCARTO in BUILDER. – ramiroaznar May 5 '17 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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