komoot / staticmap

A small, python-based library for creating map images with lines, markers and polygons.
https://www.komoot.com
Other
290 stars 65 forks source link

Add User-Agent header to solve 403 error from OpenStreetMap tile server #34

Closed narihira2000 closed 1 year ago

narihira2000 commented 1 year ago

The original tile server was changed to OpenStreetMap(OSM) tile server in 6f5f9fc. However, it will cause 403 error if there is no User-Agent in header according to OSM's Tile Usage Policy.

I just add the User-Agent in header to solve this problem.

By the way, I think it's better to add the package's version in User-Agent (e.g. StaticMap/0.5.5), one simple way to get it is to use built-in importlib.metadata.version function. Yet this function only works above python 3.8, so I gave up using this approach and only used a plain string in User-Agent in this PR.

christophlingg commented 1 year ago

thanks for the bug fix @narihira2000