I'm trying to style, e.g. museums, so that both their icon and their name shows up. However, there seems to be some conflict. Here's my - related - code:

.points {
    ::tourism {
        [tourism = 'museum'][zoom >= 17] {
            marker-placement: interior; marker-fill: @icon_fill;
            marker-file: url('icons/museum.svg');
            marker-clip: false;

#area_label[zoom>=10] {
    [type = 'museum'][zoom >= 17] {
        text-name: "[name]";
        text-fill: #111;
        text-size: 8;
        text-wrap-width: 30;
        text-line-spacing: -1.5;
        text-face-name: @sans;
        text-placement: interior;

Now, the thing is:

  • If I leave only the icon, it looks fine
  • If I leave only the label, it still looks fine
  • If I leave both, most likely only the label shows (though at times, it's only the icon that shows)
  • If I add marker-allow-overlap, it becomes a mess

I'm looking at the "official" OpenStreetMap theme, and it seems to be handling it great: At lower zoom levels, the label may not show up, but if you zoom enough (my case), both show. (To be precise, the icon is on top, and below you can find the label).

How do they achieve that? Any hints?

enter image description here

1 Answer 1


You can add labels as attachments using a CartoCSS similar to this one:

#layer {
  marker-width: 20;
  marker-fill: #EE4D5A;
  marker-fill-opacity: 0.9;
  marker-file: url('https://s3.amazonaws.com/com.cartodb.users-assets.production/maki-icons/warehouse-18.svg');
  marker-allow-overlap: true;
  marker-line-width: 1;
  marker-line-color: #FFFFFF;
  marker-line-opacity: 1;
#layer::labels {
  text-name: [name];
  text-face-name: 'DejaVu Sans Book';
  text-size: 10;
  text-fill: #FFFFFF;
  text-label-position-tolerance: 0;
  text-halo-radius: 1;
  text-halo-fill: #6F808D;
  text-dy: -10;
  text-allow-overlap: true;
  text-placement: point;
  text-placement-type: dummy;


  • Thanks a lot for your help! (Saludos desde Granada ;-) ) Oct 5, 2017 at 14:06

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.