# How Oh My Maps! Places Country Labels Automatically (and What Happens When It Can't)

How the editor decides where a country name goes when it doesn't fit inside its own borders, and what happens on a map too crowded for labels to fit at all.

> Editor: https://ohmymaps.com/ · Versão em página: https://ohmymaps.com/blog/automatic-country-label-placement/

Labelling a map by hand is a fight against overlapping text: a name too big
for its country, a small nation's label colliding with its neighbour's,
Luxembourg's name simply having nowhere to go. [Oh My Maps!](https://ohmymaps.com/)
solves this with an automatic placement algorithm rather than leaving you to
drag text boxes around one at a time.

![A cluster of small Balkan countries, each painted teal, with names placed in callout boxes just outside their borders and thin guide lines pointing back to each country](/blog/posts/label-callout-cluster.svg)

## The simple case: the name fits inside

If a country's name fits comfortably inside its own shape at the chosen font
size, that is where it goes, centred on the country. Most large and
medium-sized countries never need anything more complicated than this.

## When it doesn't fit: the callout search

When a name is too big for its country, the label does not shrink or spill
across a border. Instead, the editor searches in rings around the country
for a free spot to place a callout box, a small rectangle containing the
name, connected back to the country by a short leader line.

The search has real constraints, not just "find any empty pixel":

- It prefers water over land, so a callout is more likely to land in the
  ocean beside a coastline than on top of a neighbouring country.
- A callout box is not allowed to cover land belonging to another labelled
  country, so adding one label does not silently make another one
  unreadable.
- The search has a maximum radius, so a callout stays visually connected to
  its country rather than drifting into a distant, unrelated part of the
  map.

The result is a leader line that is usually short: a small country's name
lands just offshore, close enough that the connection to its territory is
obvious at a glance rather than a long line snaking across the map.

<div class="cta">
  <p><strong>Try it on a cluster of small countries.</strong> Turn on labels for the Balkans or the Caribbean and watch the callouts fill in around them.</p>
  <a class="cta-button" href="https://ohmymaps.com/">Open the editor</a>
</div>

## When even that fails: the numbered key

On a genuinely crowded map, dense clusters of small countries close
together, there may be no free space left within a callout's search radius
for every label to fit. When that happens, the editor does not force some
labels to overlap. Instead, the **entire set** of active labels switches to
a numbered mode: every labelled country gets a small number on the map, and
a key panel lists the numbers against the country names, positioned wherever
it fits and split into columns automatically if the list is long.

This is a set-wide switch, not a per-country fallback, on purpose: mixing
some countries with in-map names and others with numbers on the same map
would be harder to read than either format alone. If you specifically want
the numbered format, labelling a cluster of small, adjacent countries is
the fastest way to trigger it deliberately, which is a reasonable choice for
[a geography quiz where matching a number to a name is the point](/blog/geography-quiz-classroom-map/).

## What travels into the export

Callout boxes, leader lines and the numbered key panel are all drawn
directly into the map's SVG, the same source that PNG, JPEG and WebP exports
are rasterised from. There is no separate "labels for screen" versus
"labels for export" logic: what you see while editing is exactly what ships
in the file, at any resolution up to 8000 px.

## Practical takeaways

- **Label only the countries your map is actually about.** Labelling all 235
  guarantees you hit the numbered fallback; labelling six specific countries
  almost never will.
- **If a cluster keeps triggering the numbered mode and you don't want it,**
  reduce the font size for that map, which gives the callout search more
  room to place standard labels before it gives up.
- **The numbered key panel is a legitimate design choice, not just a
  fallback.** For maps with many small, similarly sized regions, it is
  often more legible than a screen full of leader lines.

## Next steps

- [The full tour of the editor](/blog/how-to-make-a-custom-world-map-online/)
  covers labels alongside painting, patterns and export.
- [How to make a geography quiz or classroom map](/blog/geography-quiz-classroom-map/)
  puts the numbered key format to deliberate use.