1

I'm using MapBox Studio to create a personalized map for slums.

In OSM we have many polygons representing buildings and I need to style them according to their "building" tag. For example, the building=hospital tag should have a red background.

I tried to select those polygons but I can't find a way This works ok as expected:

#building {
    polygon-fill: #2aeb38;
}

... but none of these work:

#building [building='hospital'],
#building [amenity='clinic'],
#building [class='clinic'],
#building [class='hospital'],
#buildings [type='hospital'],
#buildings [type='clinic']{
    polygon-fill: #e28600;
}

In Maperitive I could easily style polygons and point easily by doing:

hospital : amenity=hospital OR building=hospital OR amenity=clinic
target: hospital
    define.....

but I can't replicate this on CartoCSS. Any ideas?

2

If your styling the default source(mapbox-streets-v5) in mapbox studio you are not working with raw OSM data, you're a styling data that has already had someones opinion applied to it, and thus your options are limited. In this case the building layer does not has any fields other than osm_id, so it does not seem like your going to be able to accomplish what your looking to do using mapbox-streets-v5. This doesn't mean that you cant do this styling with mapbox studio, but you would have to make your own vector tiles that include the information that you need.

In the layers pane in mapbox studio you can view the fields associated with a layer: Mapbox studio layers pane

  • is there any other service I can input in the mapbox studio source url to have all the osm data? – Juan Aug 6 '15 at 22:04
  • Mapzen has a MVT tile service that contains more data, and include the building and amenity tags in the building layer, but it still may not contain all the tags you looking for. If you want to try it out select "Change Source" and put in the url vector.mapzen.com/osm/tilejson/mapbox.json – Jesse Crocker Aug 7 '15 at 12:22

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.