-
Notifications
You must be signed in to change notification settings - Fork 66
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
Refactor project to allow use as a dependency #146
Comments
If any useful developer tools don't specifically rely on the style or vice-versa then another would be to factor them out into their own repositories and include them as |
I agree with that approach. I'm thinking specifically of dev tools that are specific to this style. |
Because it works via the styleimagemissing event, the shield rendering code is more of a MapLibre extension than a part of the style itself. I think this means that another project offering multiple maps with a style picker would get shields rendered regardless of the currently active style. Not sure if there is a way to avoid this, but something to consider if we are going to work on making Americana usable within other projects. |
Well, the map object would either need to get destroyed and recreated or its properties updated. Really this just means we add recycling the styleimageimssing event hook along with everything else that parameterizes the maplibre map object to the list of things that need to be swapped when style swapping. I would personally not worry about those mechanics until we encounter a specific use case for how to switch styles on the fly like that. |
I guess the first use case I imagined for adding Americana as a dependency of another project was an existing MapLibre app offering multiple styles wanting to add Americana as an option. Maybe there are other use cases I'm not thinking of though. I'd expect most projects would be using a Mapbox gl plugin for style switching like one of these: |
In terms of dependencies, the use case I'm thinking of is "I want to embed an Americana map on my site and use it as a base layer" So that user would desire to take the generated style JSON, a .js file that draws the shields, and the shield blanks as input. Then they could do whatever with the map object from there. |
I'd love to be able to provide the OSM Americana style to the users of TravelMap (to trace roadtrip itineraries across the US) but I'm wary of the added code complexity and the maintenance burden for a single style. How much JS would need to be pulled-in to add the OSM Americana style? Would it be a simple npm package that needs to be added as a dependency? |
@clementmas a built style.json is now available: |
@adamfranco can you revisit the intent of this issue and assess where we are versus where we would need to be in order to satisfy the intent of "allow use as a dependency"? |
I think the main use case I was thinking of is as a base-map for an application. For example, let's say i want to provide a map application to render arbitrary custom data served from my own database (for example something like OpenCampingMap or Curvature has its own searching/filtering/navigation controls, and I want to add the Americana map rendering as a base layer over which my own data layers are rendering. I would also then want to be able to Assuming the application is using the Maplibre stack, it would be great to be able to add Americana as a dependency [in a node-based project's I think I'd need to do some more testing to see how close we're getting to meeting this use-case -- maybe we're already there, maybe not. |
I find myself here while trying to figure out the best way to add shields to my own map base style(s). I see that the shield generator has been published as its own package, which is great, but are there plans to do so for the shield definitions (and associated icons) as well? I'd love to leverage what you all have been building here! |
The sprites and shield definitions are published but they're probably not documented. Shield definitions: https://americanamap.org/shields.json |
Thank you for that, but it seems those files are not part of what's published in the openstreetmap-americana npm package. Am I missing something? I suppose I can run the build scripts in there myself if I have to, but it'd be nice to have shields.json and the sprites as something I could install with npm. |
The That said, I would welcome a better understanding about how end users would want to be able to deploy the style and explore those use cases. We are in the process of slowly breaking up the monorepo into separate repositories, with the shield library being the first of these. |
From my perspective, I would really like to use the shield generator and the shield mappings, hopefully with the protomaps basemap vector tiles. I realize that the mappings are tightly coupled to the tile data, but I've filed an issue there to hopefully get their shield data into a state that it will be compatible. I might or might not use the Americana shield images directly, as I may want an SDF version, etc. Actually, it would be awesome if Americana provided SDF sprites too! |
This project has started pretty organically and now that #137 is getting close, it may be time to think about refactoring the code for clarity for contributors.
Broadly, there are two ways that this project can be used:
The stand-alone map/demo case is currently what we've been focused on, but the inclusion of the style as a dependency of other projects shouldn't be too far off.
Here are some steps that might get us there, though I'm probably missing a few and these should be discussed:
package.json
to the root of the repository if there isn't a good reason to bury it instyle/
.index.html
out of thestyle/
directory either to the root or to ademo/
orsite/
subdirectory.americana.js
into anindex.js
ordemo.js
that goes with the demo'sindex.html
. This should leaveamericana.js
exporting a style object with all layers that is as complete as possible and which can be passed added in the demo or other map renderings after having the source tweaked to add the access key or change the source url.npm i --include=dev
. Any dependencies that are needed only when used as a library should be included by default.Thoughts? What did I miss?
I think this is blocked by #137, but I could be wrong.
The text was updated successfully, but these errors were encountered: