Kyle Barron
Kyle Barron

Reputation: 2649

Mapbox style circles at ends of linestrings

I'd like to render circles at only the ends of LineStrings, ideally without creating a separate duplicative data source.

I have LineStrings representing trails from the OpenMapTiles project. They render fine using the line layer style type, but when I try to render with the circle layer style type, it renders a circle at every vertex, and not just the ends. Is there a filter expression I could use to show these circles at only the ends?

Here's the style layer that is rendering the points in the image below:

    {
      "id": "road_path_pedestrian_trail_ends",
      "type": "circle",
      "source": "openmaptiles",
      "source-layer": "transportation",
      "minzoom": 13,
      "filter": [
        "all",
        ["==", "$type", "LineString"],
        ["!in", "brunnel", "bridge", "tunnel"],
        ["in", "class", "path", "pedestrian"],
        ["in", "subclass", "path", "footway"]
      ],
      "layout": {"visibility": "visible"},
      "paint": {}
    }

enter image description here

Upvotes: 1

Views: 733

Answers (1)

Steve Bennett
Steve Bennett

Reputation: 126517

As far as I'm aware, there is no way to distinguish a line endpoint from any other vertex.

You could maaaaaybe get something of the effect you want by rendering two lines, one with line-end: round, a different color, under the other line which has line-end: butt. You'd get a tiny half-circle thing which may be better than nothing?

Upvotes: 0

Related Questions