1

I am trying to create markers with text-labels inside in Tilemill. As I don't want close markers to overlap I have the

marker-allow-overlap:false;

Now, this does not affect the text labels of the markers, so some text is lying unmotivated in plain nowhere.

labels not affected by allow overlap

Labels for hiden markers are still visible

When setting text-allow-overlap to false the labels are now respecting the overlap but not visible on the markers anymore.

Is there a way to get markers with text-labels where the overlap-function is working on both simultaneously?

My full CartoCSS reference:

#tmp {
  marker-width:20;
  marker-fill:#f45;
  marker-line-color:#813;
  marker-allow-overlap:false;
  marker-ignore-placement:false;
  ::labels{
    text-name:"[values]";
    text-face-name:"Arial Bold";
    text-allow-overlap:true;
  }
}
0

Use shield for examples like this.

Here is the CartoCSS reference.

Here is an example to start with.

0

What you are looking for is MapBox' maker example page. I believe you have to add additional CSS markup for each zoom level. In their example, they show how to change the size of the marker-width at each zoom level. What is happening is that you don't have enough room to display the label text in the marker size. text-allow-overlap:false; fixes the problem yet removes the text. You will want to remove the label display altogether at some zoom levels and show just the marker with text-allow-overlap:false; set.

Based on your comment you will want to experiment with zoom levels in your CartoCSS. In the same link there are some additional examples that they cover but don't give you an explicit example of pulling the idea together. You will want to adjust the zoom range values so that the text turns on when you no longer have text overlap issues. Opacity of zero is like the hex color #000. All the lights are out. The default opacity value is 1 or #FFF. All the lights are on.

#tmp { marker-width:20; marker-fill:#f45; marker-line-color:#813; marker-allow-overlap:false; marker-ignore-placement:false; ::labels{ text-name:"[values]"; text-face-name:"Arial Bold"; text-allow-overlap:false; [zoom >= 0][zoom <= 12] { {text-opacity:0;} } } }

There are other opacity styles that can be used on other kinds of map features.

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

  • Thanks for the example. The thing is, I don't want different marker sizes in different zoom levels. I want same sized markers with text in all zoom levels with markers disappearing when they would overlap - exactly what the marker-allow-overlap:false; is producing. And I need to behave the marker text accordingly. Is it not possible with Tilemill? – bennos Nov 7 '14 at 7:47
  • Thanks for your suggestions. I found another solution with shields, which is exactly what I described. Please see the accepted answer. – bennos Nov 10 '14 at 7:58

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.