Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable data-driven expressions for collision properties #8454

Open
tristen opened this issue Jul 10, 2019 · 0 comments
Open

Enable data-driven expressions for collision properties #8454

tristen opened this issue Jul 10, 2019 · 0 comments
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.)

Comments

@tristen
Copy link
Member

tristen commented Jul 10, 2019

Motivation

I have a use case for setting collision conditions to larger transit labels but defaulting to defaults for minor ones. Writing a data condition that effect these properties would help a lot:

  • text-allow-overlap
  • icon-allow-overlap
  • icon-ignore-placement
  • text-ignore-placement
  • text-optional
  • icon-optional
  • text-padding
  • icon-padding

Design Alternatives

Creating a new layer to handle overlap properties. When a layer is this long, its a lot to duplicate and keep in sync:

See transit-label layer in Streets v11
{
  "id": "transit-label",
  "type": "symbol",
  "metadata": { "mapbox:featureComponent": "transit-labels", "mapbox:group": "Transit labels" },
  "source": "composite",
  "source-layer": "transit_stop_label",
  "minzoom": 12,
  "filter": [
    "step",
    ["zoom"],
    [
      "all",
      ["match", ["get", "mode"], ["rail", "metro_rail"], true, false],
      ["!=", ["get", "stop_type"], "entrance"]
    ],
    15,
    [
      "all",
      ["match", ["get", "mode"], ["rail", "metro_rail", "ferry", "light_rail"], true, false],
      ["!=", ["get", "stop_type"], "entrance"]
    ],
    16,
    ["all", ["!=", ["get", "mode"], "bus"], ["!=", ["get", "stop_type"], "entrance"]],
    17,
    ["!=", ["get", "stop_type"], "entrance"],
    19,
    true
  ],
  "layout": {
    "text-size": 12,
    "icon-image": ["get", "network"],
    "text-font": ["DIN Offc Pro Medium", "Arial Unicode MS Regular"],
    "text-justify": ["match", ["get", "stop_type"], "entrance", "left", "center"],
    "text-offset": [
      "match",
      ["get", "stop_type"],
      "entrance",
      ["literal", [1, 0]],
      ["literal", [0, 0.8]]
    ],
    "text-anchor": ["match", ["get", "stop_type"], "entrance", "left", "top"],
    "text-field": [
      "step",
      ["zoom"],
      "",
      14,
      [
        "match",
        ["get", "mode"],
        ["rail", "metro_rail"],
        ["coalesce", ["get", "name_en"], ["get", "name"]],
        ""
      ],
      16,
      [
        "match",
        ["get", "mode"],
        ["bus", "bicycle"],
        "",
        ["coalesce", ["get", "name_en"], ["get", "name"]]
      ],
      18,
      ["coalesce", ["get", "name_en"], ["get", "name"]]
    ],
    "text-letter-spacing": 0.01,
    "text-max-width": ["match", ["get", "stop_type"], "entrance", 15, 9]
  },
  "paint": {
    "text-halo-color": "hsl(35, 17%, 100%)",
    "text-color": [
      "match",
      ["get", "network"],
      "tokyo-metro",
      "hsl(180, 50%, 30%)",
      "mexico-city-metro",
      "hsl(25, 100%, 100%)",
      ["barcelona-metro", "delhi-metro", "hong-kong-mtr", "milan-metro", "osaka-subway"],
      "hsl(0, 90%, 47%)",
      ["boston-t", "washington-metro"],
      "hsl(0, 0%, 0%)",
      ["chongqing-rail-transit", "kiev-metro", "singapore-mrt", "taipei-metro"],
      "hsl(140, 90%, 25%)",
      "hsl(230, 48%, 44%)"
    ],
    "text-halo-blur": 0.5,
    "text-halo-width": 0.5
  }
}
@mourner mourner added the cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) label Jul 11, 2019
@tristen tristen changed the title Enable data-driven expressions for text-allow-overlap icon-allow-overlap Enable data-driven expressions for collision properties Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.)
Projects
None yet
Development

No branches or pull requests

2 participants