# Itabira Map

> The 79 neighborhoods of Itabira on one map

Interactive map of the 79 neighborhoods of Itabira, MG. Search any neighborhood, see its boundaries and switch to dark mode.

- **Coverage:** 79 neighborhoods of Itabira, MG
- **Data:** Boundaries, census, 97 associations, 29 health units
- **Map base:** OpenStreetMap tiles drawn with MapLibre
- **Partnership:** Inter-associations of Itabira
- **Stack:** Next.js, MapLibre, shadcn/ui

[Live site](https://itabira-map.vercel.app) · [Code](https://github.com/arthur-ba1/itabira-map)

## A partnership to bring the city’s data together

Itabira Map was born from a partnership with the city’s inter-associations, with a simple goal: put in one place data that used to live scattered. Neighborhood boundaries, census, residents’ associations and health units now share a single map of the 79 neighborhoods of Itabira, in Minas Gerais.

Instead of separate spreadsheets and lists, there is a map that anyone can open in the browser, on the phone or on the computer, and find a neighborhood in seconds.

## What you find in the app

Everything about a neighborhood is one search away, on the phone or on the computer.

- **Any neighborhood in seconds.** Type the name and the map takes you straight there. A search box lists the 79 neighborhoods and filters as you type. Picking one centers the map on it and opens its panel.
- **The numbers of each neighborhood.** Population, households, area, perimeter and charts by sex, age and color or race, all in one panel. The census spreadsheets are totaled per neighborhood before publishing, so the panel only reads ready numbers. It also lists the associations and health units registered in the neighborhood, and its legal document.
- **Get there with your own app.** Turn on the pins for associations and health units and open any of them in Google Maps or Waze, or Apple Maps on iOS. On the phone, the app first tries the native address of Google Maps or Waze; if the app does not come to the foreground, a timeout sends you to the browser version. Apple Maps needs no trick: its link is already universal on iOS.
- **Send a neighborhood by link.** Share a link with the neighborhood name and the map opens right there. The link carries a bairro parameter with the neighborhood slug. It is read once, as soon as the list of neighborhoods loads, and the map goes to that neighborhood.
- **Your way, remembered.** Paint the neighborhoods in four colors or in just one and switch between light and dark. The app remembers. Color mode and theme are saved in the browser. The page reads them before the first paint, so the map is born with the right colors instead of flashing the default ones.
- **Install it like an app.** On the phone, add it to the home screen and open it like any other app, with no browser bar. It is a web app with a manifest: standalone display, name and icons at 192 and 512 px. Nothing to download from a store.

## Scattered data, one map

Boundaries, census, associations and health units used to live in separate files. Before each release, everything is gathered, slimmed down and positioned, so the browser receives only what it needs to draw.

1. **All in one place** (4 sources): Neighborhood boundaries, six census spreadsheets, 97 associations and 29 health units, together at last. Four sources: the boundaries (GeoJSON), the census spreadsheets, the list of 97 associations and the list of 29 health units. Three scripts merge them before every build.
2. **Light for real** (−94%): The boundaries get 94% lighter without losing the shape of the neighborhoods. The map opens fast. The outlines go from 1.98 MB to 120 KB (36,844 to 4,357 points) with a line simplification algorithm. The shared edges used to color neighbors are measured before this step, on the exact coordinates.
3. **Census in every neighborhood** (103 thousand): Population, households, age and color or race, already totaled for every neighborhood. 102,963 residents and 35,976 households, summed per neighborhood from the census spreadsheets before publishing. The browser never does the math.
4. **Address becomes a point** (108 pins): Associations and health units get a spot on the map. When an address is not exact, the pin shows faded. 79 of 97 associations (7 approximate) and all 29 health units (12 approximate) got coordinates. The other 18 associations have no usable address yet. Addresses are geocoded with Nominatim; with no match, the pin falls back to the center of the neighborhood.
5. **One file, 79 neighborhoods** (225 KB): Everything the browser needs comes in a single file, ready to be drawn over the OpenStreetMap map. Outline, census numbers, associations, health units and the color of each neighborhood come together in one 225 KB file that MapLibre draws over the OpenStreetMap base.

## Choices that make a difference

- **Fast by design.** The heavy work happens before publishing. The browser only draws, and the map opens fast even on the phone. Preprocessing scripts run before every build: outlines are simplified (1.98 MB to 120 KB, 36,844 to 4,357 points), the census is totaled per neighborhood and everything is merged. Each neighborhood arrives with outline, census numbers, associations and health units in one 225 KB file.
- **Readable at a glance.** Neighboring neighborhoods never share a color, so the borders read clearly with just four colors. Neighbors are found from the edges that two outlines share, measured on the original coordinates before simplifying. A greedy coloring that starts from the neighborhoods with the most neighbors then picks the colors, and the result is saved with each neighborhood.
- **Pins that stay put.** They do not lag or drift when you drag and zoom. The pins are circle layers of the map itself (MapLibre, drawn with WebGL from a GeoJSON source), not HTML elements floating above it, so they move in the same frame as the map.
- **Honest about precision.** When an address cannot be found, the pin shows faded, so nobody mistakes it for an exact location. Addresses are turned into coordinates with Nominatim (OpenStreetMap), restricted to the city. With no valid match, the pin goes to the center of the neighborhood, marked as such in the data, drawn with lower opacity and described in the popup as an approximate location.
- **Dark mode at no cost.** The map base is free OpenStreetMap, with no paid key or subscription. The tiles are requested through a route of the app itself, which fetches them from OpenStreetMap and caches each one for 24 hours (and serves a stale copy for up to a week while it refreshes). No API key anywhere.

## Status

It is live on Vercel and the code is open on GitHub. Of the 97 associations, 79 got a position on the map, 7 of them approximate; the other 18 have no usable address yet. Of the 29 health units, 12 are approximate.

---

[Arthur Vinícius](https://arthurba1.com/en/) · [Português](https://arthurba1.com/pt/projects/itabira-map/index.md) · [English](https://arthurba1.com/en/projects/itabira-map/index.md) · [Español](https://arthurba1.com/es/projects/itabira-map/index.md) · [llms.txt](https://arthurba1.com/llms.txt)
