StaticMaps (staticmaps v0.1.0)

Copy Markdown View Source

Render a map to an image on the server.

render/1 takes a centre, a zoom and a size, fetches the tiles that cover that view from a StaticMaps.Source, stitches them into one image and returns the encoded bytes.

Summary

Functions

Renders a map and returns the encoded image.

Functions

render(opts)

@spec render(keyword()) :: {:ok, binary()} | {:error, Exception.t()}

Renders a map and returns the encoded image.

Options

  • :center — {lat, lng} in degrees, required
  • :zoom — integer zoom within the source's range, required
  • :source — a module implementing StaticMaps.Source, or {module, opts}; defaults to StaticMaps.Source.OSM
  • :size — {width, height} in pixels before :scale, at most {2048, 2048}; defaults to {600, 400}
  • :scale — 1 or 2; defaults to 1
  • :format — :png or :jpeg; defaults to :png
  • :background — "#rrggbb", "#rgb" or {r, g, b}, painted wherever no tile covers the image; defaults to "#e0e0e0"
  • :on_tile_error — :fail returns {:error, %StaticMaps.TileError{}} when any tile cannot be fetched or decoded; :fill paints those tiles with :background and returns the image anyway. Defaults to :fail.

Returns {:error, %ArgumentError{}} for invalid options.