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

Add bathymetry outline layer to base theme. #186

Merged
merged 2 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions site/src/Layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ export const layers = [
activeColor: "hsla(17, 17%, 92%, 1)",
labelColor: "hsla(0, 0%, 0%, 0)",
},
{
theme: "base",
type: "bathymetry",
outline: true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The bathymetry layer is exclusively polygons. I chose an outline over a fill layer because the inner area of the bathymetry polygons overlap with land, leading to irrelevant clicks. Outline layers better represent boundaries.

color: "hsla(195, 71%, 80%, 1)",
activeColor: "hsla(195, 77%, 85%, 1)",
},
{
theme: "base",
type: "land",
Expand Down
8 changes: 7 additions & 1 deletion site/src/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ const MAP_STYLE = {
};

const ThemeSource = ({ name, url }) => {
return <Source id={name} type="vector" url={`${url}${name}.pmtiles`} />;
return (
<Source
id={name}
type="vector"
url={`${url}${name}${name === "base" ? "_canary" : ""}.pmtiles`}
/>
);
};

ThemeSource.propTypes = {
Expand Down
16 changes: 16 additions & 0 deletions site/src/ThemeTypeLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ const ThemeTypeLayer = ({
{...(minzoom ? { minzoom } : {})}
/>
) : null}
{outline ? (
<Layer
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add an invisible line which is larger than the rendered outline to enable easier clicks.

filter={["==", ["geometry-type"], "Polygon"]}
id={`${theme}_${type}_outline_click_buffer`}
type="line"
source={theme}
source-layer={type}
paint={{
"line-opacity": 0,
"line-color": "black",
"line-width": ["interpolate", ["linear"], ["zoom"], 12, 6, 13, 9],
}}
layout={{ visibility: visible ? "visible" : "none" }}
{...(minzoom ? { minzoom } : {})}
/>
) : null}
{label && line ? (
<Layer
filter={["==", ["geometry-type"], "LineString"]}
Expand Down
Loading