Labeling Polygons

christ.stark's Avatar

christ.stark

08 Oct, 2011 08:45 AM

Hi, I would like to label Polygons of a shape. The names for the polygons are in my table-column N5.
so I took the code from the geography-class example and tried to use that but it doesn't work:

/* LABELS!!  Fonts and font sets can be assigned to variables. The first font
   will be preferred, and fall back to subsequent fonts for characters
   that are not available, or if the entire font is not available to
   Mapnik. */
@futura_med: "Futura Medium","Function Pro Medium","Ubuntu Regular","Trebuchet MS Regular","DejaVu Sans Book";
@futura_italic: "Futura Medium Italic","Function Pro Medium Italic","Ubuntu Italic","Trebuchet MS Italic","DejaVu Sans Oblique";
@futura_bold: "Futura Bold","Function Pro Bold","Ubuntu Bold","Trebuchet MS Bold","DejaVu Sans Bold";

/* ---- Bundeslaender Schrift ---- */
#Bundeslaender[zoom>1][TYPE='Sovereign country'],
#Bundeslaender[zoom>1][TYPE='Country']{
  text-face-name: @futura_med;
  text-fill:@line * 0.6;
  text-size:9;
  text-transform:uppercase;
  text-halo-fill:rgba(255,255,255,0.5);
  text-halo-radius:1;
  text-line-spacing:1;
  text-wrap-width:20;
  text-name:"''"; /* hackish? */

  [zoom=3] { 
    text-size:10; 
  }
  [zoom=4] { 
    text-size:11; 
  }
  [zoom=5] { 
    text-size:12;
    text-character-spacing:1;
    text-line-spacing:1;
  }
  [zoom>5] {
    text-size:14;
    text-character-spacing:2;
    text-line-spacing:2;
  }

  [zoom>=2][zoom<4] { text-name: "[N4]"; }
  [zoom>=4] { text-name: "[N5]"; }

}

#Bundeslaender[zoom>4][TYPE='Dependency']{
  text-face-name: @futura_italic;
  text-fill:@line * 0.6;
  text-size:9;
  text-halo-fill:rgba(255,255,255,0.5);
  text-halo-radius:1;
  text-line-spacing:1;
  text-wrap-width:20;
  text-name:"[N5]";
  [zoom=6] { text-size:10; }
  [zoom>6] { text-size:11; }
}

What I didn't get is where I should link to the N5 column. The code I put into the style.mss

could anybody here help me with this problem?
best regards desputin

ps This code-block editing is a big mystery to me. What am I doing wrong?

  1. Support Staff 2 Posted by Tom MacWright on 11 Oct, 2011 02:27 PM

    Tom MacWright's Avatar

    Hey Chris,

    As far as the code blocks, backticks only work on inline code, unfortunately. You can indent long stretches of code by indenting a line or all lines 4 spaces.

    So, in the datasource inspector in TileMill, you can see the column N5 and it's specifically N5? The column selection is case-sensitive. Are you running TileMill from the OSX executable?

    If you're running the OSX executable, can you open Window -> Console from the .app and see if there are any error messages while you're viewing the style? If Mapnik can't find the column, it'll log a list of columns that it can find and that you can display.

  2. 3 Posted by christ.stark on 12 Oct, 2011 09:42 PM

    christ.stark's Avatar

    Hi Tom,

    thanks for the answer.

    No, I'm running ubuntu. Where can I find the error console there?
    I'm familiar with case sensitivity of unix based systems and it really is N5 which is right there in bold letters.
    (It also could be that there is something wrong with the shape-file or the dbf because the color assignment for one of the polygons within this layer is not working even though it is definitely assigned correctly...)

  3. Support Staff 4 Posted by Tom MacWright on 12 Oct, 2011 09:44 PM

    Tom MacWright's Avatar

    If you're running Ubuntu, any errors that TileMill gets internally should be in the terminal in which you started ./tilemill. Is there anything there?

  4. Tom MacWright closed this discussion on 12 Oct, 2011 09:44 PM.

  5. Tom MacWright re-opened this discussion on 12 Oct, 2011 09:44 PM

  6. Will White closed this discussion on 24 Nov, 2011 04:43 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

19 Jun, 2013 02:28 AM
18 Jun, 2013 11:02 PM
18 Jun, 2013 10:52 PM
18 Jun, 2013 09:29 PM