-
Notifications
You must be signed in to change notification settings - Fork 329
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
Conversation
#1121 adds default tile layer and allows user to pass a tile object to map
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 9 Ignored Deployments
|
🦋 Changeset detectedLatest commit: 8e34967 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -14,6 +14,11 @@ import 'leaflet/dist/leaflet.css'; | |||
import * as L from 'leaflet'; | |||
|
|||
export type MapProps = { | |||
tile?: { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
tileLayerName: TileLayerPreset (MapBox, OpenStreetMap, Esri, custom, .... )
tileLayerOptions: L.TileLayerOptions
cc @demenech
tile?: { | ||
attribution?: string; | ||
url: string; | ||
data?: any; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now this is all defined in TileLayerPresets object
cc @demenech
attribution='© <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} /> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented this approach in latest commit
cc @demenech
@@ -43,6 +43,13 @@ type Story = StoryObj<MapProps>; | |||
export const GeoJSONPolygons: Story = { | |||
name: 'GeoJSON polygons map', | |||
args: { | |||
tile : { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do it next @demenech
Hey @willy1989cv let me know if you were able to address feedback from @demenech |
@anuveyatsu @demenech At the moment I've implemented the more flexible approach, giving the user the possibility to configure the tile layer using component properties or .env variables. |
@willy1989cv is this now good for a re-review? |
Hi @rufuspollock. Working on the adjustments as suggested by @demenech. |
@demenech please review latest changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @willy1989cv
Very small change request, otherwise looks fine to me.
I'd like to suggest two other things:
-
There should be a way to add markdown documents to Storybook stories, perhaps we could embed your documentation in the stories somehow?
-
Just confirm this was tested on an external project after the project being built to ensure it works properly e.g. with the env vars
if (providers[providerName].url?.includes('{variant}') && !variantName) | ||
variantName = Object.keys(providers[providerName].variants)[0]; | ||
|
||
console.log(variantName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
@demenech working fine on my localhost @portaljs instance. configured through properties:
or via .env
cc: @anuveyatsu |
hey @willy1989cv |
#1121 adds default tile layer and allows user to pass a tile object to map