Questions about getting from OSM to displaying a vector map with maplibre-gl-js #5562
-
I'm relatively new to this so I might not have all of the lingo down. First general question: Is there a tutorial that shows the whole process from downloading a .pbf from OpenStreetMap to displaying generated vector tiles from martin with maplibre-gl-js for just a generic map? More details: I've already successfully gone through the following process:
I'm not sure if I'm thinking about this correctly but I think I'm getting hung up with how to easily import the OpenStreetMap data and translate that into the creation of the style.json. I tried taking one of the publicly available styles from maputnik and just change the source. That didn't really work since, for example, it seems how OpenMapTiles data is set up differently than how mine was when I used the generic.lua style for the postgresql import. To use the OpenMapTiles template I was having to go through and change every layer and key, even then some items were not successfully switched to my data source. Otherwise do I need to manually generate the style.json listing every single key and value from OpenStreetMaps? I guess I'm looking for suggestions on how I should be approaching this process. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
The process in general is correct, but you might want to simplify it:
The key thing to understand is that a style and the sources (tiles) are very much linked together - when writing a style you should know the underling data, it's properties, and what it represents in order to show it on the map. |
Beta Was this translation helpful? Give feedback.
-
You don't need to throw out anything if you don't want to, but it will save you time. Historically, osm2pgsql was widely used for generating raster tiles. It is still functional but is no longer the most efficient choice for vector tile generation, especially for large-scale data. It is significantly slower compared to alternatives like Imposm or Planetiler. And as you already experienced, the lack of predefined vector tile styles also makes it harder to use. If you need a PostGIS-based solution, then OpenMapTiles is a better choice, as it uses Imposm, which is better optimized than osm2pgsql for this use case and has predefined styles you can build on. If you’re only serving tiles and don’t need a PostGIS database, then planetiler-openmaptiles is a better choice. It can generate vector tiles much faster. |
Beta Was this translation helpful? Give feedback.
-
Adding this comment to close this out and maybe help someone who finds this in the future. I've yet to see a good flowchart describing the whole map making process with pros and cons of using various options along the way. https://wiki.openstreetmap.org/wiki/Vector_tiles was a decent read though. I believe what I was describing doing for the osm2pgsql import was create as schema to do the styling, which is exactly what OpenMapTiles is. I ended up taking the advice suggested and using the OpenMapTiles quickstart to get started and go from there. |
Beta Was this translation helpful? Give feedback.
Adding this comment to close this out and maybe help someone who finds this in the future. I've yet to see a good flowchart describing the whole map making process with pros and cons of using various options along the way. https://wiki.openstreetmap.org/wiki/Vector_tiles was a decent read though.
I believe what I was describing doing for the osm2pgsql import was create as schema to do the styling, which is exactly what OpenMapTiles is. I ended up taking the advice suggested and using the OpenMapTiles quickstart to get started and go from there.