How do I get a static map image of a Swedish municipality?
<img src="https://api.kart-api.se/v1/render/karta?lat=58.7052&lng=15.7803&zoom=11&w=800&h=450"
width="800" height="450" alt="Map of Finspång">That is the whole solution. No map in the browser, no library, no key.
Framing the whole municipality
Fetch the boundary first and pass its bounding box:
curl -s 'https://api.kart-api.se/v1/kommun/0562' | jq -r '
[.geometry.coordinates[][][]] as $p |
"bbox=\([$p[][0]]|min),\([$p[][1]]|min),\([$p[][0]]|max),\([$p[][1]]|max)"'then:
https://api.kart-api.se/v1/render/karta?bbox=15.36,58.55,16.20,58.99&w=800&h=600Or let us frame it
https://api.kart-api.se/v1/render/vinjett?kommun=0562&w=600&h=400The vignette is the orientation image — the one that shows where in the country the municipality is. It is only delivered if it can be filled: otherwise 503 with lagsta_fyllande_zoom, instead of an image with holes.
What to expect
The first call is rendered for real and can take up to ~20 seconds; after that the image is cached. The credit is burned into the pixels — don't crop it out, it is the licence condition.