2

OK, so I have a CartoCSS project.

These are all of the stylesheets used (as described in my project.mml):

  "Stylesheet": [
    "palette.mss", 
    "base.mss", 
    "roads.mss", 
    "labels.mss",
    "extras.mss"
  ],

In the labels.mss file, I'm styling the labels. Here's the part I'm interested in:

#minorroad_label[zoom>15] {
  text-name:'[name]';
  text-face-name:@sans;
  text-placement:line;
  text-size:9;
  text-fill:@street_text;
  text-halo-fill:@road_halo;
  text-halo-radius:1;
  text-min-distance:60;
  text-size:11;
  text-allow-overlap: false;
}

#minorroad_label[oneway!=0][zoom>=16]{
  marker-placement:line;
  marker-height:1;
  marker-fill: #bbb;
  marker-line-opacity:0;
  marker-spacing: 250;
}

/* ================================================================== */
/* ONE-WAY ARROWS
/* ================================================================== */
#motorway_label[zoom>=16],
#mainroad_label[zoom>=16],
#minorroad_label[zoom>=16] {
  [oneway = 'yes'],
  [oneway='-1'] {
     marker-placement:line;
     marker-max-error: 0.5;
     marker-spacing: 200;
     marker-file: url(img/oneway.svg);
     marker-fill: white;
     [oneway='-1'] { marker-file: url(img/oneway-reverse.svg); }
     [zoom=16] { marker-transform: "scale(0.5)"; }
     [zoom=17] { marker-transform: "scale(0.75)"; }
  }
}

In the extras.mss file, I'm setting up the amenity icons. Here's an example:

.points { 

    ::amenity {

        [amenity = 'arts_centre'][zoom >=17] {
            marker-transform: scale(@icon_scale); 
            marker-placement: interior; 
            marker-fill: @icon_fill;
            marker-file: url('icons/shop/art.svg');
        }

        [amenity = 'atm'][zoom >=17] {
            marker-transform: scale(@icon_scale); marker-placement: interior; marker-fill: @icon_fill;
            marker-file: url('icons/atm.svg');
        }

        //[amenity = 'bank'][zoom >=17] {
        //  marker-placement: interior; marker-fill: @icon_fill;
        //  marker-file: url('icons/bank.svg');
        //}

        [amenity = 'bar'][zoom >= 17] {
            marker-transform: scale(@icon_scale); marker-placement: interior; marker-fill: @icon_fill;
            marker-file: url('icons/bar.svg');
        }

        [amenity = 'biergarten'][zoom >= 17] {
            marker-transform: scale(@icon_scale); marker-placement: interior; marker-fill: @icon_fill;
            marker-file: url('icons/biergarten.svg');
        }

        [amenity = 'cafe'][zoom >= 17] {
            marker-transform: scale(@icon_scale); marker-placement: interior; marker-fill: @icon_fill;
            marker-file: url('icons/cafe.svg');
        }

        [amenity = 'pub'][zoom >= 17] {
            marker-transform: scale(@icon_scale); marker-placement: interior; marker-fill: @icon_fill;
            marker-file: url('icons/pub.svg');
        }

        [amenity = 'restaurant'][zoom >= 17],
        [amenity = 'food_court'][zoom >= 17] {
            marker-transform: scale(@icon_scale); marker-placement: interior; marker-fill: @icon_fill;
            marker-file: url('icons/restaurant.svg');
        }
    }
}

Now the problem is, in places where there are a lot of cafes or restaurants for example, all I can see the related icons -- with the street names, nowhere to be found.

What it looks like with the above code

enter image description here

What it looks like if I remove the icons altogether

enter image description here

What I want to do is: make the street names appear no matter what, and IF there is enough space for the icons, then that's fine. But the street names (#minorroad_label namely) should have priority over the icons.

I've tried moving things around, changing the order of the stylesheets, putting the icons' part before the labels, or after the labels, as if it'd affect the priority, but to no avail. I've also played with text-allow-overlap and marker-allow-overlap. Well, setting them to true does make them appear, but then it's a mess; definitely not what I want.

Any ideas/suggestions?

2

For all of you who may come across this question, here's how I resolved:

I just changed the sequence of the layers in the project.mml file, by putting the labels' related ones first.

(Yep, I had moved things around a lot in almost all files, except for the right one)

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.