A pure OpenStreetMap viewer and renderer developed with Qt 6, featuring classic map style rendering. Browse and view only, no map editing functionality included.
- Multi-format Support: Supports OSM XML (.osm) and PBF (.osm.pbf) map data formats
- Self-contained Parsing: Built-in zero-dependency Protobuf PBF parser, no external protobuf library required
- Classic Map Style Rendering:
- Classic #f2efe9 beige background
- Double-layer road rendering (CASING outline + NORMAL body)
- Real-world width mapping, road width dynamically changes with zoom
- Road width differentiated by grade (footway 1.5m to motorway 25m)
- Railway dashed lines, water area filling, green space/building area rendering
- Layered transparency effects, upper elements more transparent
- FlatCap+MiterJoin pen style, smooth road junctions without bumps
- Road direction arrows and one-way arrows display, arrow size differentiated by road grade
- Interactive Functions: Mouse drag pan, scroll wheel zoom
- Layer Control: Independent toggle controls for each layer
- Roads (H), Buildings (B), Water (W), Green Space (G)
- Railways (Shift+R), Land Use (L), Nodes (N)
- Show/Hide All buttons
- Road Navigation: Road direction arrows, one-way small arrows display
- Search Function: Search road features by name, supports quick location to geographic coordinates
- Road Highlighting: Highlight effect when hovering and selecting roads, highlight width matches actual road width
- High-performance Rendering: 512×512 tile parallel rendering, LRU cache (max 64 tiles)
- Coordinate Correction: Latitude correction processing to avoid road stretching distortion in high-latitude regions
- MapCSS Style Customization:
- Support import/export MapCSS style files
- Auto-loads
map-style.mapcssconfiguration file - Customizable colors, line widths, transparency and other rendering parameters
- Built-in default style, one-click restore
- Distance Threshold Control: Auto show/hide roads at corresponding levels based on zoom level, optimizing performance
- Qt 6.11.1 (MinGW 64-bit)
- MinGW 13.1.0
- zlib (statically linked, no additional DLL required)
# Clean old build files
mingw32-make.exe clean
# Generate Makefile
qmake.exe ViewOSMMap.pro
# Build (8 threads)
mingw32-make.exe -j8
# Deploy Qt dependency DLLs
C:\Qt\6.11.1\mingw_64\bin\windeployqt.exe --compiler-runtime release\ViewOSMMap.exeAfter building, the executable file is located at release/ViewOSMMap.exe.
├── main.cpp / mainwindow.* # Main program entry and window UI
├── osmmodel.* # OSM data model (Node/Way/Relation)
├── osmparser.* # Parser abstract factory interface
├── osmpbfparser.* # PBF binary format parser (built-in protobuf decoding)
├── osmstyle.* # Map style definitions (colors, line widths, levels)
├── osmmapwidget.* # Map rendering core (QPainter drawing, tile caching)
├── osmquadtree.* # Spatial index quadtree
├── osmsearch.* # Road search functionality
├── osmmapcss.* # MapCSS parser and style generation
├── osmevents.* # Event handling
├── map-style.mapcss # MapCSS style configuration file (customizable)
└── release/ # Build output directory (contains executable and Qt dependencies)
- After launching the program, load .osm or .osm.pbf files via "File" → "Open"
- Use mouse scroll wheel to zoom, drag to pan the map
- Toggle layer visibility via toolbar buttons or keyboard shortcuts
- Use the search box to search for road names
The program supports customizing map styles via MapCSS files:
- Auto-load: On startup, the program automatically reads
map-style.mapcssin the same directory as the executable. If the file doesn't exist, it automatically generates a default style file - Load Custom Style: Load custom .mapcss or .css files via "Style" → "Load MapCSS Style" menu
- Export Style: Export current style to a file for editing via "Style" → "Export MapCSS Style" menu
- Restore Default: Reset to built-in hardcoded style via "Style" → "Restore Default Style" menu
fill-color/fill: Area fill colorfill-opacity: Area fill opacity (0.0-1.0)color: Line body colorwidth: Line body width (px)opacity: Line opacity (0.0-1.0)casing-color: Road outline colorcasing-width: Road outline width (px)casing-opacity: Road outline opacitydashes: Dash pattern, e.g.,8,6means 8px solid + 6px gapz-index: Layer drawing orderbackground-color: Canvas background color- Supports
|zN-syntax to specify minimum display zoom level
| Shortcut | Function |
|---|---|
| Ctrl+O | Open OSM file |
| Ctrl+S | Export PNG image |
| Ctrl+Q | Quit program |
| +/= | Zoom in |
| - | Zoom out |
| H | Toggle roads display |
| B | Toggle buildings display |
| W | Toggle water display |
| G | Toggle green space display |
| Shift+R | Toggle railways display |
| L | Toggle land use display |
| N | Toggle nodes display |
| Feature Type | Color | Description |
|---|---|---|
| Background | #f2efe9 | Beige |
| Water | #8cc8ff | Light blue fill |
| Forest/Green | #a0d28c / #beebaa | Green tones |
| Buildings | #dcbec8 | Lavender |
| Residential | #f5f0e6 | Cream |
| Motorway | #ff6432 | Orange-red with dark red outline |
| Trunk | #ff783c | Orange with dark red outline |
| Primary | #ffb450 | Golden orange with brown outline |
| Secondary | #ffdc64 | Light yellow |
| Tertiary/Residential | #dcdcdc / #f0f0f0 | White/light gray |
| Footway/Cycleway | #96dc96 | Light green |
| Railway | #787878 | Gray dashed |
| Waterway | #64b4ff | Blue line |
| Administrative | #c86464 | Red dashed |
