Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Enable within Expression with layout property #16194

Merged
merged 3 commits into from
Feb 12, 2020

Conversation

zmiao
Copy link
Contributor

@zmiao zmiao commented Feb 12, 2020

This pr implement usage of within expression with layout property. Currently the usage is: [within, geoJSONObj]. It returns true if the feature is inside the geometry boundary that defined by geoJSONObj. geoJSONObj should be inlined.

Following example shows how to set different text contents based on the feature's geometry location.

{
        "id": "text",
        "type": "symbol",
        "source": "points",
        "layout": {
            "text-field": ["case", ["within", {
                "type": "Polygon",
                "coordinates": [
                    [
                      [0, 0],
                      [0, 5],
                      [5, 5],
                      [5, 0],
                      [0, 0]
                    ]
                  ]
                }], "In", "Out"],
            "text-font": [
                "Open Sans Semibold",
                "Arial Unicode MS Bold"
            ],
            "text-size": 10
          },
          "paint" : {
            "text-color": "red"
          }
 }

@zmiao zmiao self-assigned this Feb 12, 2020
@zmiao zmiao added the needs changelog Indicates PR needs a changelog entry prior to merging. label Feb 12, 2020
@zmiao zmiao requested review from alexshalamov and pozdnyakov and removed request for alexshalamov February 12, 2020 13:29
Copy link
Contributor

@alexshalamov alexshalamov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, +changelog

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs changelog Indicates PR needs a changelog entry prior to merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants