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

Custom Tile Layer for Map Component #1122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

willy1989cv
Copy link
Member

#1121 adds default tile layer and allows user to pass a tile object to map

#1121 adds default tile layer and allows user to pass a tile object to map
Copy link

vercel bot commented May 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
portaljs-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 13, 2024 2:06pm
8 Ignored Deployments
Name Status Preview Comments Updated (UTC)
portaljs-alan-turing ⬜️ Ignored (Inspect) May 13, 2024 2:06pm
portaljs-ckan ⬜️ Ignored (Inspect) May 13, 2024 2:06pm
portaljs-ckan-ssg ⬜️ Ignored (Inspect) May 13, 2024 2:06pm
portaljs-fivethirtyeight ⬜️ Ignored (Inspect) May 13, 2024 2:06pm
portaljs-git-example ⬜️ Ignored (Inspect) May 13, 2024 2:06pm
portaljs-learn ⬜️ Ignored (Inspect) May 13, 2024 2:06pm
portaljs-openspending ⬜️ Ignored (Inspect) May 13, 2024 2:06pm
site-portaljs ⬜️ Ignored (Inspect) May 13, 2024 2:06pm

Copy link

changeset-bot bot commented May 13, 2024

⚠️ No Changeset found

Latest commit: a6047a9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -14,6 +14,11 @@ import 'leaflet/dist/leaflet.css';
import * as L from 'leaflet';

export type MapProps = {
tile?: {
Copy link
Member

@demenech demenech May 13, 2024

Choose a reason for hiding this comment

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

IMO we should support both this flexible approach + the default providers from this lib https://github.com/leaflet-extras/leaflet-providers

This tile prop (which I think could be renamed to something like tileLayerSettings for more clarity) should have an interface like:


type UrlTileLayerSettings = { url: string }

// based on https://github.com/leaflet-extras/leaflet-providers
type MapboxTileLayerSettings = {     
  id: string,
  accessToken: string 
}   

type TileLayerSettings = UrlTileLayerSettings | MapboxTileLayerSettings // ...

...
tileLayerSettings: TileLayerSettings

tile?: {
attribution?: string;
url: string;
data?: any;
Copy link
Member

Choose a reason for hiding this comment

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

Is this prop used anywhere?

attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<TileLayer url={tile.url} attribution={tile.attribution} {...tile.data} />
Copy link
Member

Choose a reason for hiding this comment

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

Based on which provider was chosen, we can pass different props to this component.

I think you can do an implementation based on this code https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js

@@ -43,6 +43,13 @@ type Story = StoryObj<MapProps>;
export const GeoJSONPolygons: Story = {
name: 'GeoJSON polygons map',
args: {
tile : {
Copy link
Member

Choose a reason for hiding this comment

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

We should document this new parameter on the story

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.

None yet

2 participants