# Maps

Draw a map of a dungeon, cave or village in Dunjii, number its areas, and show it in your session pages.

## Making a map

On a session's page, choose **Add a map**. Anywhere else, choose **New file**, then **Map**. Type a name in the sidebar and press Enter, and the map editor opens.

![The tool bar: Sketch, Terrain, Brush, Shape and Text.](https://dunjii.com/docs-assets/writing/map-maker.webp)

A new map is 40 × 28 squares of solid rock that you draw rooms into. For a cave or a village, choose **Open floor** under **Start as** at the bottom left, and erase walls and rock out of open ground instead. The choice goes away once you draw something.

Dunjii saves a map as two files: `Barn Cellars.svg` contains the drawing, and `Barn Cellars.metadata.md` contains the labels, the key and the print settings. The map takes its colors from the theme of the page it is shown on.

## Drawing

The tools are on the bar at the top of the editor. Each has a key.

| Tool | Key | What it does |
| ---- | --- | ------------ |
| **Sketch** | K | Paints floor. Dunjii reads each stroke as a room or a hallway, and draws the walls and the rock around the floor for you. |
| **Erase** | E | Erases floor. X switches between Sketch and Erase. Hold ⌥ to do the other for one stroke. |
| **Terrain** | W | What Sketch paints: Floor, Water, Trees, Rocks or Trail. |
| **Brush** | [ ] | Squares, or Round, for caves (Q switches). 1, 2, 3 or 5 squares wide, or any width from 0.1 to 5. Wall draws walls inside a room. |
| **Shape** | R, O, S | A rectangle, ellipse or star. A shape can be an outline, solid or hatched, and can hold a word such as "Table". A small shape across a wall reads as a door. |
| **Text**, **Number** | T, L | Words on the map, or a number for the key. |

Hold Shift to paint a straight line. Strokes snap to the grid; hold ⌘ on a Mac, Ctrl elsewhere, to draw freehand. Press the grip in the middle of a room to move it, and its hallways follow. To curve a hallway, select one of its points and choose **Make it smooth**, or double-click the point. ⌘Z undoes.

## Labels and the key

Press L and click a room to put a number on it, then type the room's name. The number and the name go into the key beside the map. Numbers count up in the order you place them. Press T to write text on the map instead.

![A selected number with its name and the note it opens.](https://dunjii.com/docs-assets/writing/map-label.webp)

A selected label's bar has:

- the kind: **Number in a disc**, **Plain number** or **Text**
- the name that goes in the key
- **Link to a note or map**, which completes as you type. A linked number, and its line in the key, open that note.

Drag a corner of a label to change its size, from 3 to 36 points. Turn a text label with the dot above it. **Key** on the bar at the bottom lists every number, and picking one selects it.

## Map settings

**Map settings** on the bar at the bottom of the editor opens the settings for the whole map.

![The map settings.](https://dunjii.com/docs-assets/writing/map-settings.webp)

- **Squares**: how many squares across and down, from 4 to 100. You can also drag from outside an edge of the paper with Sketch.
- **Grid snap**: what strokes and drags snap to, ¼, ½, 1 or 2 squares.
- **Rock**: how the rock around the rooms is drawn: Ink and wash, Contour and wash, Broken strata, Line engraving or Crosshatch.
- **Printed width**: from 4 to 120 inches. **Fit one page** prints the map and its key as large as fits on one page of your paper.
- **Clear map**: **All rock** or **All floor**.

The labels and settings are in the `.metadata.md` file. A key at its default is left out.

```markdown
---
type: overview-map
overviewMap:
  outputWidthIn: 9.7
  fitPage: true
  snapSquares: 0.5
  rockStyle: strata
  legendPlacement: right
  labels:
    - text: Tithe store
      xPx: 2600
      yPx: 500
      numeric: true
      fontPt: 20
      link: "[[The Tithe Barn]]"
---
```

- `fitPage: true`: Printed width, and Fit one page.
- `rockStyle: strata`: Grid snap and Rock.
- `legendPlacement: right`: Where the key goes: right, left, or float for a box on the map.
- `yPx: 500`: Where the label is, at 100 pixels to a square.
- `numeric: true`: A number in the key. false writes the text on the map.
- `link: "[[The Tithe Barn]]"`: The note the number opens.

## Maps in pages

Embed a map by its file name. Dunjii draws it in the page's theme, with its key under it. When you change the map, every page that embeds it shows the change.

```markdown
![[Barn Cellars.svg]]
```

![The map embedded in a page, with its key.](https://dunjii.com/docs-assets/writing/map-embed.webp)

**Image…** in the editor lists maps on its **Choose an image** tab, so you can also pick one there. **Print** on the map's own page prints it at its printed width. **Copy or download as PNG** on the editor's bar makes a picture of the map at up to 100 pixels a square. When the map has numbers, **Include the key** adds the key to the picture.

## Uploaded maps

A map drawn in another program can be uploaded as a picture. Open it and choose a type in the menu at the top of its page:

- **Overview Map**: click the map to add numbers and text, with the same label bar as a drawn map. Select the key to dock it left or right or float it on the map. **Map settings** sets the printed width, **Fit one page** and the orientation.
- **Battle Map**: drag a rectangle over the map's grid, and Dunjii finds the grid lines in the artwork and fits a grid to them. See [Battle maps](https://dunjii.com/docs/layout-and-printing/battle-maps.md) for printing it at tabletop scale.

Both kinds can print in black and white, from **Image** on the map's bar.
