How come these map projects still use raster tiles? Are there no open source map projects that render the OSM data to vector data, and renders that vector data on the clients GPU? Maybe raster tiles are better at something I'm missing, but vector maps are easier to style[0], localize, they're sharper, easier to rotate and zoom smoothly. Maybe it's harder than I think to render it on all sorts of clients including mobile?
When writing this I found out that MapTiler[1] is maintaining MapLibre GL JS[2], a fork of a Mapbox project to do just that. It would be interesting to see the difference between self hosting raster and vector maps and compare pros and cons. You can even render raster tiles from vector tiles on the server if the client needs it[3].
Just to set the record straight: MapTiler is *not* the maintainer of MapLibre. MapTiler is *one of* many participating companies in the MapLibre organization, which has a board and a charter [1].
Amazon has donated $300,000 to MapLibre, Facebook - $80,000, TomTom - $10,000, and lots more companies have donated. Most of the code maintenance is done by various volunteers and companies, e.g. Amazon has hired a whole team of engineers to work on MapLibre native, etc.
P.S. I came up with the name MapLibre, called people to unite around this effort, and am on the board of the MapLibre organization. [2]
If you want to display infinite fractional zoom levels, WebGL is mandatory. That's what most consumers will expect from a high fidelity map application, because that's the way Google and Apple Maps work.
High Fidelity.. Pity their road names don't zoom up to some degree.. it is so hard to read the road names, that as an old bugger i need a magnifying glass..
The vector tiles are much smaller in filesize than pixel data and the rendering technology is much better. Almost all the styling is done on the client side so the server is basically just querying a spatial database.
Seems like MapTiler is maintaining an open source full stack vector alternative, and OpenLayers[0] looks good as well, so maybe it's time for legacy libraries to add vector support, or for users to switch libraries? There's even bindings from Maplibre GL to Leaflet [1].
I at least would find it interesting to see the two compared by someone other than me ;).
Nice! Only on Hacker news can you make a comment about some kind of hypothetical programming project and have the reply be "Yes, I've made one of those already".
Do you think it's still too early to switch to vector map data for all clients then? Maybe render raster tiles on demand on the server to those clients that can't handle it?
The barriers to adopting vector-everywhere are social and commercial, not technical.
There are a couple great public raster services like osm.org's default style and http://maps.stamen.com. These are 100% free to use, so they get used everywhere, but incur significant expense to the organizations running (paying) for them.
Thanks for this. I remember using MVTs on HTML Canvas with Leaflet via plugin way back in 2017.[1] It wasn't perfect, but browser rendering has definitely been the bigger issue than anything with Leaflet.
I'm surprised I don't see more implementations caching and serving vector tiles. I know some (most?) large mapping companies do this.
I maintain a heavily used map of the US, and I found that storing data/serving in vector format seems to be the most efficient (on AWS s3 / DO spaces), and converting to raster in the browser or with a service call / lambda really opens the doors to a lot more use cases. I suspect parent can talk more about this than I can.
vector tiles are years-old now.. there are a dozen decent implementations.. why would Leaflet not support vector tiles ? is there some commercial agreement behind closed doors regarding crippled Leaflet now?
Because Leaflet is an extensible library for building map UIs using the browser, using DOM elements as grid cells, and using SVG in some cases for overlay geometry and user interaction.
Things that are mandatory for map display, like:
- Label priority and positioning
- Display of internationalized, RTL, and Bidi text
- Geometry rasterization and styling
Are outside the scope of Leaflet's core design and can be implemented by plugins, one of which I have linked in a sibling comment.
Small note of clarification about MapLibre. It's a vendor-neutral, community-led project supported by a lot of different industry participants (including AWS & Meta).
The transitions seem really smooth and the user experience is pleasant... until I open them on an Android device that came out just 2 years ago (one of those rugged models), in Firefox.
I'm sure that the slowness has something to do with rendering vector data, because all of the sudden those maps become unusable - slow zooming, slow loading (possibly the data is fetched reasonably quickly, just slow to display), slow scrolling. In a word, laggy. When looking at an area of my choice, using the vector maps (even after letting them load fully) I get probably less than 10 frames per second so panning feels choppy.
On the other hand, the raster maps are basically what you'd get when panning across an image - the latter experience remains reasonably smooth. There, the only disadvantage is the typical swapping out of raster tiles as you zoom in or out, but that's a small nuisance at best, apart from the visual difference in quality.
As it currently stands, if we all used only vector data, I feel like a lot of people on lower spec devices would be left out. I wonder whether any serious tests have been made on the battery usage or performance of both types, but even tests this simple show that there are certain problems with the current implementations of vector maps.
Note: this isn't meant to be a super accurate comparison, but rather a quick look into some of the immediately apparent practical differences in what the user experience is like.
> The transitions seem really smooth and the user experience is pleasant... until I open them on an Android device that came out just 2 years ago (one of those rugged models), in Firefox.
My daily driver is a Samsung Galaxy S4 (2014) with LineageOS and Firefox (Fennec F-Droid, no google services).
Your link works pretty well, it took a few seconds to load the map, but zooming and panning is quite smooth, it seems.
Edit: panning is much less smooth on openstreetmap. It's faster to bring in new features when zooming, but you have to endure blurry text and less details for half a second or so. Also, you can't rotate the view. IIRC google maps renders text locally to solve that.
> Your link works pretty well, it took a few seconds to load the map, but zooming and panning is quite smooth, it seems.
This is exactly why I recorded a video and put one in that blog post - because sometimes people that are running even the same software will have vastly different experiences. At the end of the day "But it works/doesn't work on my machine." is just the reality that we need to deal with - which will vary for someone with a weaker or more powerful device, certain browser, certain drivers and so on.
> Panning is much less smooth on openstreetmap.
I'd say that from the best to worst for me it'd go a bit like this: Google Maps (application) > OpenStreetMap (web) > Google Maps (web) > MapLibre GL JS (web)
> It's faster to bring in new features when zooming, but you have to endure blurry text and less details for half a second or so.
Same here!
> Also, you can't rotate the view.
I can't rotate the view in Google Maps (web) either, only in the native app.
For me, the web maps also seem to use raster tiles, whereas the application seems to use vector data, added more info in another comment: https://news.ycombinator.com/item?id=33712150
That's strange, it works flawlessly on my 2018 phone, although that has a Snapdragon 845 which was considered the fastest SoC available for Android phones at the time. How is the Google Maps, OsmAnd, or Mapbox experience on your phone? They also use vector map data.
If you need to support old underpowered devices you can serve raster tiles to them. I don't know how to automatically detect which type to send to a device, one way would be to just time how long it takes to render a frame of vector data and switch to raster maps if the device is too slow, or at least present the user with the option.
> How is the Google Maps, OsmAnd, or Mapbox experience on your phone? They also use vector map data.
Google Maps (in Firefox) seem to be slow when loading data in, but decent when panning around. Though it does appear that they're using raster based tiles (I can quite literally see pixels when I zoom in, before the new tile loads and replaces the one for the previous zoom level).
Google Maps (Android app) seem to be really smooth when panning around, but also similarly slow when loading data in. Zooming is a bit sluggish, but not as bad as vector tiles when viewed through the browser.
I also remember using the HERE maps application a long time ago on an even slower device, somehow those performed way better than Google Maps application though.
My suspicions: a browser might have greater overhead, maybe not everything plays nicely with Firefox or my hardware. The slow data loading seems to be caused by the CPU/GPU instead of the network connection, because if new tiles are loaded in while I'm panning around, the movement also lags.
> If you need to support old underpowered devices you can serve raster tiles to them. I don't know how to automatically detect which type to send to a device, one way would be to just time how long it takes to render a frame of vector data and switch to raster maps if the device is too slow, or at least present the user with the option.
This is a good idea, provided that the people serving the maps would be interested in supporting both formats.
Firefox seems to have very inconsistent behaviour on Mapbox/Maplibre sites. I deal with a lot of bug reports with no pattern to them except Firefox is slow but on the same device, Chrome is perfect...
In addition to the links others have given I'd note that serving dynamically generated Mapbox Vector Tiles (MVT) can be done very easily from a very standard postgis server these days [0]. For me this is the no brainer way to go. Your main problem is likely to be converting from OSM's labyrinthine data structure to something easier to serve.
The zoom is especially bad with raster OSM right now since they only support zoom up to level 19, which results in a lot of pixelation if you want to go closer than seeing an entire street.
But with vector tiles you (normally) start overzooming at level 15, resulting in either much less detail or really large file sizes for a zoom 14 vector tile that would have to carry all the data to be used in overzooming.
So raster tiles load much faster and OpenStreetMap retina tiles help against pixelation.
And you can - though not advisable for large areas - render raster tiles at much higher zoom levels, e.g. SomeOneElse renders his raster style up to level 28 for the UK.
Couldn't you take this into consideration in the vector renderer? A lot of roads and paths in OSM have width and surface tags, you could render that using some appropriate texture on high zoom levels instead of the usual dotted lines for paths. Forest and grass doesn't have to be solid green fields, and crosswalks and traffic lights could be rendered, contour lines can have user specified intervals, and so on. There's lot's of additional detail you can render parametrically from data.
Well that is true, the vector tiles do have the opposite problem of having too much data when zoomed out, but using raster beyond level 21 is just completely wasteful in terms of storage required. Most of the tiles will just be one colour. I'm not sure how level 28 is even possible without taking up multiple HDDs.
I still think that the more proper solution would be to instead cap out the vector tiles on the other end, not going lower than say level 5.
Both arguments of yours are quite true, I also don't think that going beyond zoom level 20 or 21 is advisible within a raster tile stack (and I just checked that the UK map I mentioned earlier goes up to zoom 24 and not 28 as I stated, while the software stack (in this case mod_tile&renderd) is prepared for up to zoom 28).
I also don't intend to argue against a vector tile stack - both vector and raster have their use cases and pro's and con's.
Vector tiles bring much more flexibility but less support in some use cases, raster normally loads/displays much faster (if served pre-rendered) and has universal support on the client side.
Yeah I mean if you ask me what the optimal solution is it would have to be a combination of the two, more specifically vector data overlaid on top of satelite imagery.
Unfortunately I'm not really aware of any FOSS dataset for that yet, but that may change in the coming decades if the price of mass to orbit goes down.
My experience with it is that vector tiles can become very CPU-heavy on the client, specially when moving into 3D space like with MapLibre's terrain layers.
It's less computationally expensive to just fetch a pre-rendered tile and drape it onto the map, which keeps rotating, panning an tilting very performant.
It doesn't look that nice, so there's the tradeoff. It can also be easier to just cache tiles on the end device and resort to them instead of constantly reassemble the vector layers.
Raster tiles are smaller in terms of amount data sent over the wire and work better for users with less powerful computers/ mobile
Really if you aren't interacting with the data on the client I would stick with good old rasters - it's harder to get set up with them but they perform way better
OsmAnd uses offline vector tiles as standard, they support multiple different styles including custom ones. It performs fine on my phone, and it shows off many of the benefits with vector data. It's easy to choose which kind of point of interest you want displayed, hike and bike routes can be colored in, I think it uses much less storage space on the phone. You can add raster maps to OsmAnd if you want to though.
When writing this I found out that MapTiler[1] is maintaining MapLibre GL JS[2], a fork of a Mapbox project to do just that. It would be interesting to see the difference between self hosting raster and vector maps and compare pros and cons. You can even render raster tiles from vector tiles on the server if the client needs it[3].
[0] https://openmaptiles.org/docs/style/mapbox-gl-style-spec/
[1] https://www.maptiler.com/open-source/
[2] https://github.com/MapLibre/maplibre-gl-js
[3] https://openmaptiles.org/docs/host/tileserver-gl/