maplibre / maplibre-gl-js

MapLibre GL JS - Interactive vector tile maps in the browser
https://maplibre.org/maplibre-gl-js/docs/
Other
6.61k stars 712 forks source link

improve docs for raster source parameter: tileSize #1257

Open ttomasz opened 2 years ago

ttomasz commented 2 years ago

Not setting this parameter can have significant effect on how the map is displayed when using e.g. OpenStreetMap's tiles.

I am attaching two files with examples (apparently github doesn't allow attaching html files so they are suffixed with txt).

It seems that with the raster source serving 256px tiles:

It would be nice if this was documented so people avoid making blurry maps by accident. maplibre_test.html.txt maplibre_test2.html.txt image

wipfli commented 2 years ago

Intersting, thanks. Ideally you share a stackblitz or jsbin or codesandbox or so. Then others can just click on the link and see the problem dirctly in their browser. But thanks still for the htmls!

I wonder if we have an example on the docs website with osm tiles?

ttomasz commented 2 years ago

Yeah, I actually initially made stackblitz snippets as I thought the issue was with me rewriting my app to react but forgot about them :sweat_smile: https://stackblitz.com/edit/js-cactms?file=index.html

ttomasz commented 2 years ago

There is one example of adding XYZ tiles with different tile provider (and style) https://maplibre.org/maplibre-gl-js-docs/example/map-tiles/

wipfli commented 2 years ago

Ah that sort of hand-painted map from Stamen looks really nice :)

image

This example uses osm tiles: https://maplibre.org/maplibre-gl-js-docs/example/3d-extrusion-floorplan/

xabbu42 commented 2 years ago

From my understanding, the blurry maps are the result of maplibre-gl-js assuming the default tile size of 512px and then getting 256px tiles instead. I suppose we could log an error in this case (i.e. getting tiles with the wrong size from a raster source)?

Also I do not understand the current description of the tileSize parameter https://maplibre.org/maplibre-gl-js-docs/style-spec/sources#raster-tileSize at all (I'm not a native speaker). So I definitely agree that this documentation should be improved.

dnomadb commented 2 years ago

I'd love to take a stab at this as I think tileSize is one of GL-JS's more underrated features. I've used it multiple times to:

I actually had this page kicking around to show how it can work: https://dnomadb.github.io/tile-size/?tileSize=2048&resampling=nearest

HarelM commented 2 years ago

Should I move this issue to the docs repo?

dnomadb commented 2 years ago

Should I move this issue to the docs repo?

@HarelM Since the documentation for this aspect of the style spec is contained here: https://github.com/maplibre/maplibre-gl-js/blob/608c0fa3e6050072786ded848353ff3be3dd8579/src/style-spec/reference/v8.json#L254, I think it makes sense to leave it in this repo.

That said, I think that a simplified example of how this is used (potentially similar to the above) would add a lot of clarity, so I could open a new issue there if people are 👍 .

HarelM commented 2 years ago

I don't think a new issue is needed. Feel free to submit a PR.