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

New renderTransparent() configuration option #406

Merged
merged 2 commits into from
Dec 14, 2021
Merged

Conversation

ahocevar
Copy link
Member

@ahocevar ahocevar commented Dec 13, 2021

This pull request adds an option to render transparent content, e.g. invisible polygon fills, for hit detection. Example: when you want to have parcels rendered only with their outline, but want the whole parcel to be clickable, configure your style with

  "layers": [
    {
      "id": "parcel",
      "source": "parcels",
      "type": "fill",
      "paint": {
        "fill-color": "rgba(0, 0, 0, 0)"
      }
    }, {
      "id": "parcel-outline",
      "source": "parcels",
      "type": "line",
      "paint": {
        "line-color": "rgb(0, 0, 0)",
        "line-width": 0.5
      }
    }
  ]

In your application code, configure the new option:

import { renderTransparent } from 'ol-mapbox-style/dist/stylefunction';
renderTransparent(true);

Fixes #108.

@ahocevar ahocevar merged commit 6e8651c into main Dec 14, 2021
@ahocevar ahocevar deleted the render-transparent branch December 14, 2021 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transparent polygon fill in stylesheet has no hit detection
1 participant