# `StaticMaps.Marker`
[🔗](https://gitlab.com/tristanperalta/staticmaps/blob/v0.1.0/lib/static_maps/marker.ex#L1)

A point marked on the map.

The default marker is a pin 24 × 36 logical pixels, with its tip on the coordinate, so
it extends 12 pixels either side of the point and 36 above it. A custom icon has its
own size, and its anchor is the pixel that sits on the coordinate. Fitting the view
counts the whole marker, not just the point, so a pin near the edge is never cut off.

## Options

  * `:color` — the default pin's colour, `"#rgb"`, `"#rrggbb"` or `{r, g, b}`
  * `:label` — up to three characters written in the default pin's head
  * `:icon` — SVG or image bytes to draw instead of the default pin
  * `:anchor` — `{x, y}` in the icon's pixels that sits on the coordinate; defaults to
    the middle of the icon's bottom edge

# `extent`

```elixir
@type extent() ::
  {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()}
```

Pixels a marker reaches from its coordinate: `{left, top, right, bottom}`.

# `icon`

```elixir
@type icon() :: %{bytes: binary(), kind: :svg | :raster}
```

A custom icon: its bytes, whether they are SVG, which is drawn sharp at any scale, or a
raster image, which is scaled up for `scale: 2`.

# `t`

```elixir
@type t() :: %StaticMaps.Marker{
  anchor: {non_neg_integer(), non_neg_integer()},
  color: [0..255],
  icon: icon() | nil,
  label: String.t() | nil,
  lat: number(),
  lng: number(),
  size: {pos_integer(), pos_integer()}
}
```

# `extent`

```elixir
@spec extent(t()) :: extent()
```

How far `marker` reaches from its coordinate, in logical pixels.

    iex> StaticMaps.Marker.extent(%StaticMaps.Marker{lat: 0, lng: 0})
    {12, 36, 12, 0}

# `new`

```elixir
@spec new(number(), number(), keyword()) :: {:ok, t()} | {:error, String.t()}
```

Builds a marker from its options, or says which option is wrong.

# `pin_svg`

```elixir
@spec pin_svg(t()) :: String.t()
```

The SVG of a default pin, `24 × 36` with its tip at the bottom centre.

Text in it is escaped, so a label cannot inject markup.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
