{"id":13610926,"url":"https://github.com/flopp/go-staticmaps","last_synced_at":"2025-05-15T10:06:58.786Z","repository":{"id":41933748,"uuid":"50774831","full_name":"flopp/go-staticmaps","owner":"flopp","description":"A go (golang) library and command line tool to render static map images using OpenStreetMap tiles.","archived":false,"fork":false,"pushed_at":"2025-05-09T15:30:26.000Z","size":1495,"stargazers_count":352,"open_issues_count":5,"forks_count":71,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-09T16:41:49.948Z","etag":null,"topics":["geo","gis","go-staticmaps","map","maps","openstreetmap","tilemap","tiles"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flopp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-01-31T13:07:10.000Z","updated_at":"2025-05-07T05:23:43.000Z","dependencies_parsed_at":"2024-04-21T09:43:56.364Z","dependency_job_id":"f4e02886-bec2-45b9-b0bd-16d0449248b0","html_url":"https://github.com/flopp/go-staticmaps","commit_stats":{"total_commits":151,"total_committers":20,"mean_commits":7.55,"dds":"0.22516556291390732","last_synced_commit":"c226716bec537e7edd9be9df4297f5141bbb6d29"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flopp%2Fgo-staticmaps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flopp%2Fgo-staticmaps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flopp%2Fgo-staticmaps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flopp%2Fgo-staticmaps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flopp","download_url":"https://codeload.github.com/flopp/go-staticmaps/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319720,"owners_count":22051073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geo","gis","go-staticmaps","map","maps","openstreetmap","tilemap","tiles"],"created_at":"2024-08-01T19:01:49.506Z","updated_at":"2025-05-15T10:06:53.773Z","avatar_url":"https://github.com/flopp.png","language":"Go","readme":"[![PkgGoDev](https://pkg.go.dev/badge/github.com/flopp/go-staticmaps)](https://pkg.go.dev/github.com/flopp/go-staticmaps)\n[![Go Report Card](https://goreportcard.com/badge/github.com/flopp/go-staticmaps)](https://goreportcard.com/report/flopp/go-staticmaps)\n![golang/static](https://github.com/flopp/go-staticmaps/workflows/golang/static/badge.svg)\n[![License MIT](https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/flopp/go-staticmaps/)\n\n# go-staticmaps\nA go (golang) library and command line tool to render static map images using OpenStreetMap tiles.\n\n## What?\ngo-staticmaps is a golang library that allows you to create nice static map images from OpenStreetMap tiles, along with markers of different size and color, as well as paths and colored areas.\n\nFor a Python version with a similar interface, take a look at [py-staticmaps](https://github.com/flopp/py-staticmaps).\n\ngo-staticmaps comes with a command line tool called `create-static-map` for use in shell scripts, etc.\n\n![Static map of the Berlin Marathon](https://raw.githubusercontent.com/flopp/flopp.github.io/master/go-staticmaps/berlin-marathon.png)\n\n## How?\n\n### Installation\n\nInstalling go-staticmaps is as easy as\n\n```bash\ngo get -u github.com/flopp/go-staticmaps\n```\n\nFor the command line tool, use\n```bash\ngo get -u github.com/flopp/go-staticmaps/create-static-map\n```\n\nOf course, your local Go installation must be setup up properly.\n\n### Library Usage\n\nCreate a 400x300 pixel map with a red marker:\n\n```go\npackage main\n\nimport (\n  \"image/color\"\n\n  sm \"github.com/flopp/go-staticmaps\"\n  \"github.com/fogleman/gg\"\n  \"github.com/golang/geo/s2\"\n)\n\nfunc main() {\n  ctx := sm.NewContext()\n  ctx.SetSize(400, 300)\n\tctx.SetZoom(14)\n  ctx.AddObject(\n    sm.NewMarker(\n      s2.LatLngFromDegrees(52.514536, 13.350151),\n      color.RGBA{0xff, 0, 0, 0xff},\n      16.0,\n    ),\n  )\n\n  img, err := ctx.Render()\n  if err != nil {\n    panic(err)\n  }\n\n  if err := gg.SavePNG(\"my-map.png\", img); err != nil {\n    panic(err)\n  }\n}\n```\n\n\nSee [PkgGoDev](https://pkg.go.dev/github.com/flopp/go-staticmaps) for a complete documentation and the source code of the [command line tool](https://github.com/flopp/go-staticmaps/blob/master/create-static-map/create-static-map.go) for an example how to use the package.\n\n\n### Command Line Usage\n\n    Usage:\n      create-static-map [OPTIONS]\n\n    Creates a static map\n\n    Application Options:\n          --width=PIXELS              Width of the generated static map image (default: 512)\n          --height=PIXELS             Height of the generated static map image (default: 512)\n      -o, --output=FILENAME           Output file name (default: map.png)\n      -t, --type=MAPTYPE              Select the map type; list possible map types with '--type list'\n      -c, --center=LATLNG             Center coordinates (lat,lng) of the static map\n      -z, --zoom=ZOOMLEVEL            Zoom factor\n      -b, --bbox=nwLATLNG|seLATLNG    Bounding box of the static map\n          --background=COLOR          Background color (default: transparent)\n      -u, --useragent=USERAGENT       Overwrite the default HTTP user agent string\n      -m, --marker=MARKER             Add a marker to the static map\n      -i, --imagemarker=MARKER        Add an image marker to the static map\n      -p, --path=PATH                 Add a path to the static map\n      -a, --area=AREA                 Add an area to the static map\n      -C, --circle=CIRCLE             Add a circle to the static map\n\n    Help Options:\n      -h, --help                      Show this help message\n\n### General\nThe command line interface tries to resemble [Google's Static Maps API](https://developers.google.com/maps/documentation/static-maps/intro).\nIf neither `--bbox`, `--center`, nor `--zoom` are given, the map extent is determined from the specified markers, paths and areas.\n\n`--background` lets you specify a color used for map areas that are not covered by map tiles (areas north of 85°/south of -85°).\n\n### Markers\nThe `--marker` option defines one or more map markers of the same style. Use multiple `--marker` options to add markers of different styles.\n\n    --marker MARKER_STYLES|LATLNG|LATLNG|...\n\n`LATLNG` is a comma separated pair of latitude and longitude, e.g. `52.5153,13.3564`.\n\n`MARKER_STYLES` consists of a set of style descriptors separated by the pipe character `|`:\n\n- `color:COLOR` - where `COLOR` is either of the form `0xRRGGBB`, `0xRRGGBBAA`, or one of `black`, `blue`, `brown`, `green`, `orange`, `purple`, `red`, `yellow`, `white` (default: `red`)\n- `size:SIZE` - where `SIZE` is one of `mid`, `small`, `tiny`, or some number \u003e 0 (default: `mid`)\n- `label:LABEL` - where `LABEL` is an alpha numeric character, i.e. `A`-`Z`, `a`-`z`, `0`-`9`; (default: no label)\n- `labelcolor:COLOR` - where `COLOR` is either of the form `0xRRGGBB`, `0xRRGGBBAA`, or one of `black`, `blue`, `brown`, `green`, `orange`, `purple`, `red`, `yellow`, `white` (default: `black` or `white`, depending on the marker color)\n\nUsing the `--imagemarker` option, you can use custom images as markers:\n\n    --imagemarker image:IMAGEFILE|offsetx:OFFSETX|offsety:OFFSETY|LATLNG|LATLNG|...\n\n`IMAGEFILE` is the file name of a PNG or JPEG file,\n\n`OFFSETX` and `OFFSETY` are the pixel offsets of the reference point from the top-left corner of the image.\n\n### Paths\nThe `--path` option defines a path on the map. Use multiple `--path` options to add multiple paths to the map.\n\n    --path PATH_STYLES|LATLNG|LATLNG|...\n\nor\n\n    --path PATH_STYLES|gpx:my_gpx_file.gpx\n\n`PATH_STYLES` consists of a set of style descriptors separated by the pipe character `|`:\n\n- `color:COLOR` - where `COLOR` is either of the form `0xRRGGBB`, `0xRRGGBBAA`, or one of `black`, `blue`, `brown`, `green`, `orange`, `purple`, `red`, `yellow`, `white` (default: `red`)\n- `weight:WEIGHT` - where `WEIGHT` is the line width in pixels (defaut: `5`)\n\n### Areas\nThe `--area` option defines a closed area on the map. Use multiple `--area` options to add multiple areas to the map.\n\n    --area AREA_STYLES|LATLNG|LATLNG|...\n\n`AREA_STYLES` consists of a set of style descriptors separated by the pipe character `|`:\n\n- `color:COLOR` - where `COLOR` is either of the form `0xRRGGBB`, `0xRRGGBBAA`, or one of `black`, `blue`, `brown`, `green`, `orange`, `purple`, `red`, `yellow`, `white` (default: `red`)\n- `weight:WEIGHT` - where `WEIGHT` is the line width in pixels (defaut: `5`)\n- `fill:COLOR` - where `COLOR` is either of the form `0xRRGGBB`, `0xRRGGBBAA`, or one of `black`, `blue`, `brown`, `green`, `orange`, `purple`, `red`, `yellow`, `white` (default: none)\n\n\n### Circles\nThe `--circles` option defines one or more circles of the same style. Use multiple `--circle` options to add circles of different styles.\n\n    --circle CIRCLE_STYLES|LATLNG|LATLNG|...\n\n`LATLNG` is a comma separated pair of latitude and longitude, e.g. `52.5153,13.3564`.\n\n`CIRCLE_STYLES` consists of a set of style descriptors separated by the pipe character `|`:\n\n- `color:COLOR` - where `COLOR` is either of the form `0xRRGGBB`, `0xRRGGBBAA`, or one of `black`, `blue`, `brown`, `green`, `orange`, `purple`, `red`, `yellow`, `white` (default: `red`)\n- `fill:COLOR` - where `COLOR` is either of the form `0xRRGGBB`, `0xRRGGBBAA`, or one of `black`, `blue`, `brown`, `green`, `orange`, `purple`, `red`, `yellow`, `white` (default: no fill color)\n- `radius:RADIUS` - where `RADIUS` is te circle radius in meters (default: `100.0`)\n- `weight:WEIGHT` - where `WEIGHT` is the line width in pixels (defaut: `5`)\n\n\n## Examples\n\n### Basic Maps\n\nCentered at \"N 52.514536 E 13.350151\" with zoom level 10:\n\n```bash\n$ create-static-map --width 600 --height 400 -o map1.png -c \"52.514536,13.350151\" -z 10\n```\n![Example 1](https://raw.githubusercontent.com/flopp/flopp.github.io/master/go-staticmaps/map1.png)\n\nA map with a marker at \"N 52.514536 E 13.350151\" with zoom level 14 (no need to specify the map's center - it is automatically computed from the marker(s)):\n\n```bash\n$ create-static-map --width 600 --height 400 -o map2.png -z 14 -m \"52.514536,13.350151\"\n```\n\n![Example 2](https://raw.githubusercontent.com/flopp/flopp.github.io/master/go-staticmaps/map2.png)\n\nA map with two markers (red and green). If there are more than two markers in the map, a *good* zoom level can be determined automatically:\n\n```bash\n$ create-static-map --width 600 --height 400 -o map3.png -m \"color:red|52.514536,13.350151\" -m \"color:green|52.516285,13.377746\"\n```\n\n![Example 3](https://raw.githubusercontent.com/flopp/flopp.github.io/master/go-staticmaps/map3.png)\n\n\n### Create a map of the Berlin Marathon\n\n    create-static-map --width 800 --height 600 \\\n      --marker \"color:green|52.5153,13.3564\" \\\n      --marker \"color:red|52.5160,13.3711\" \\\n      --output \"berlin-marathon.png\" \\\n      --path \"color:blue|weight:2|gpx:berlin-marathon.gpx\"\n\n![Static map of the Berlin Marathon](https://raw.githubusercontent.com/flopp/flopp.github.io/master/go-staticmaps/berlin-marathon.png)\n\n### Create a map of the US capitals\n\n    create-static-map --width 800 --height 400 \\\n      --output \"us-capitals.png\" \\\n      --marker \"color:blue|size:tiny|32.3754,-86.2996|58.3637,-134.5721|33.4483,-112.0738|34.7244,-92.2789|\\\n        38.5737,-121.4871|39.7551,-104.9881|41.7665,-72.6732|39.1615,-75.5136|30.4382,-84.2806|33.7545,-84.3897|\\\n        21.2920,-157.8219|43.6021,-116.2125|39.8018,-89.6533|39.7670,-86.1563|41.5888,-93.6203|39.0474,-95.6815|\\\n        38.1894,-84.8715|30.4493,-91.1882|44.3294,-69.7323|38.9693,-76.5197|42.3589,-71.0568|42.7336,-84.5466|\\\n        44.9446,-93.1027|32.3122,-90.1780|38.5698,-92.1941|46.5911,-112.0205|40.8136,-96.7026|39.1501,-119.7519|\\\n        43.2314,-71.5597|40.2202,-74.7642|35.6816,-105.9381|42.6517,-73.7551|35.7797,-78.6434|46.8084,-100.7694|\\\n        39.9622,-83.0007|35.4931,-97.4591|44.9370,-123.0272|40.2740,-76.8849|41.8270,-71.4087|34.0007,-81.0353|\\\n        44.3776,-100.3177|36.1589,-86.7821|30.2687,-97.7452|40.7716,-111.8882|44.2627,-72.5716|37.5408,-77.4339|\\\n        47.0449,-122.9016|38.3533,-81.6354|43.0632,-89.4007|41.1389,-104.8165\"\n\n![Static map of the US capitals](https://raw.githubusercontent.com/flopp/flopp.github.io/master/go-staticmaps/us-capitals.png)\n\n### Create a map of Australia\n...where the Northern Territory is highlighted and the capital Canberra is marked.\n\n    create-static-map --width 800 --height 600 \\\n      --center=\"-26.284973,134.303764\" \\\n      --output \"australia.png\" \\\n      --marker \"color:blue|-35.305200,149.121574\" \\\n      --area \"color:0x00FF00|fill:0x00FF007F|weight:2|-25.994024,129.013847|-25.994024,137.989677|-16.537670,138.011649|\\\n        -14.834820,135.385917|-12.293236,137.033866|-11.174554,130.398124|-12.925791,130.167411|-14.866678,129.002860\"\n\n![Static map of Australia](https://raw.githubusercontent.com/flopp/flopp.github.io/master/go-staticmaps/australia.png)\n\n## Acknowledgements\nBesides the go standard library, go-staticmaps uses\n\n- [OpenStreetMap](http://openstreetmap.org/), [Thunderforest](http://www.thunderforest.com/), [OpenTopoMap](http://www.opentopomap.org/), [Stamen](http://maps.stamen.com/) and [Carto](http://carto.com) as map tile providers\n- [Go Graphics](https://github.com/fogleman/gg) for 2D drawing\n- [S2 geometry library](https://github.com/golang/geo) for spherical geometry calculations\n- [gpxgo](github.com/tkrajina/gpxgo) for loading GPX files\n- [go-coordsparser](https://github.com/flopp/go-coordsparser) for parsing geo coordinates\n\n## Contributors\n- [Kooper](https://github.com/Kooper): fixed *library usage examples*\n- [felix](https://github.com/felix): added *more tile servers*\n- [wiless](https://github.com/wiless): suggested to add user definable *marker label colors*\n- [noki](https://github.com/Noki): suggested to add a user definable *bounding box*\n- [digitocero](https://github.com/digitocero): reported and fixed *type mismatch error*\n- [bcicen](https://github.com/bcicen): reported and fixed *syntax error in examples*\n- [pshevtsov](https://github.com/pshevtsov): fixed *drawing of empty attribution strings*\n- [Luzifer](https://github.com/Luzifer): added *overwritable user agent strings* to comply with the OSM tile usage policy \n- [Jason Fox](https://github.com/jasonpfox): added `RenderWithBounds` function\n- [Alexander A. Kapralov](https://github.com/alnkapa): initial *circles* implementation\n- [tsukumaru](https://github.com/tsukumaru): added `NewArea` and `NewPath` functions\n\n## License\nCopyright 2016, 2017 Florian Pigorsch \u0026 Contributors. All rights reserved.\n\nUse of this source code is governed by a MIT-style license that can be found in the LICENSE file.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflopp%2Fgo-staticmaps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflopp%2Fgo-staticmaps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflopp%2Fgo-staticmaps/lists"}