1

I've recently started to use mapbox' TileMill2 to play around with vector tiles. It's pretty nice and, in comparison to Tilemill(1), much more faster. Exactly what I was searching for.

Now I'm trying to visualize certain entities with their icon and label, for example only police stations and restaurants. Placing the icons only for those features works, but not the labeling part. Although the labels for the chosen entitites are placed, but unfortunately also all other. Maybe you have an idea on how to solve my problem? I've already checked the references, but no success.

Find below the corresponding css stuff and a picture )right click on picture and "open in new tab" for bigger pic), which shows the problem:
[-] Only restaurants and police stations got visualized by icons (this is exactly the behavious, which I want to have)
[-] Restaurants and police stations got labeled. This is also the right behaviour.
[-] Everything else is labeled. I don't want this :-/ I've thougt that the ::label-part would solve this. But probably there is an error.!

#poi_label[zoom>=15] {
  // Separate icon and label attachments are created to ensure that
  // all icon placement happens first, then labels are placed only
  // if there is still room.

  ::icon[maki='police'] {
    // The [maki] field values match a subset of Maki icon names, so we
    // can use that in our url expression.
    // Not all POIs have a Maki icon assigned, so we limit this section
    // to those that do. See also <https://www.mapbox.com/maki/>
    marker-fill:#666;
    marker-file:url('icon/police-12.svg');
  }

  ::label {
    text-name: @name;
    text-face-name: @sans_md;
    text-size: 10;
    text-fill: #f55;
    // text-transform: uppercase;
    // text-character-spacing:  0.25;
    // POI labels with an icon need to be offset:
    [maki='police'] { text-dy: 8; }
  }

  ::icon[maki='restaurant'] {
    // The [maki] field values match a subset of Maki icon names, so we
    // can use that in our url expression.
    // Not all POIs have a Maki icon assigned, so we limit this section
    // to those that do. See also <https://www.mapbox.com/maki/>
    marker-fill:#666;
    marker-file:url('icon/restaurant-12.svg');
  }

    ::label {
    text-name: @name;
    text-face-name: @sans_md;
    text-size: 10;
    text-fill: #f55;
    // text-transform: uppercase;
    // text-character-spacing:  0.25;
    // POI labels with an icon need to be offset:
    [maki='restaurant'] { text-dy: 8; }
  }
}

Labeling Error (right click on picture and "open in new tab" for bigger pic)

2
  • Recommend you change the title to reflect TileMill 2, not 1 – rgareth4 Aug 12 '14 at 8:30
  • Jepp...you're right. I have changed the title to the right tilemill version ;) – schlomm Aug 13 '14 at 14:51
2

I've finally found the issue. I was not too far away, but the needed parameter was missing.
What you have to do, if you want to place icons and labels only for certain entities (entities are based on OSM): Define the category in the #poi_label
Find below the used example for visualizing only police-stations and restaurants with labels and icons:

#poi_label[zoom>=15][maki='police'] {
  ::icon[maki='police'] {
    marker-fill:#666;
    marker-file:url('icon/police-12.svg');
  }

  ::label {
    text-name: @name;
    text-face-name: @sans_md;
    text-size: 10;
    text-fill: #f55;
    [maki='police'] { text-dy: 8; }
  }
}

#poi_label[zoom>=15][maki='restaurants'] {
  ::icon[maki='restaurants'] {
    marker-fill:#666;
    marker-file:url('icon/restaurants-12.svg');
  }

    ::label {
    text-name: @name;
    text-face-name: @sans_md;
    text-size: 10;
    text-fill: #f55;
    [maki='restaurants'] { text-dy: 8; }
  }
}

enter image description here This works flawlessly and is exactly that, what I want to have :)

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.