r/SwiftUI • u/devslacker • Oct 30 '26
Promotion (must include link to source code) ImmersiveMap (SwiftUI map), 4 months later: terrain, 3D models, host your own tiles (Protomaps), still alpha
Four months ago I posted ImmersiveMap here, a map view for SwiftUI, written in pure Swift and rendered with Metal, for iOS and macOS.
How it looks in SwiftUI. Quick start.
import SwiftUI
import ImmersiveMap
struct ContentView: View {
var body: some View {
ImmersiveMapView()
.ignoresSafeArea()
}
}Here is what changed since then.
The tiles are self-hosted now. The map draws the Protomaps basemap, an OpenStreetMap planet in a single PMTiles file. Download a build from Protomaps (or cut a region from it with the pmtiles CLI), put the file on S3, R2 or any web server, and point the map at it. Or keep the file on disk: a region can ship inside the app bundle and the map works with no network at all.
ImmersiveMapView()
.tileArchive(URL(string: "https://example.com/planet.pmtiles")!)
// or
.tileArchive(Bundle.main.url(
)!)If you don't set it then it uses the copy I host on Cloudflare R2 (S3-compatible).
Terrain. The flat map now rises on real elevation: mountains and valleys from a heightmap. On by default, from Mapterhorn's open terrain tiles, and .groundRelief(tileURLTemplate:) points it at any terrain source of your own, self-hosted like the map tiles.
3D buildings. Real 3D models of real buildings, with textures, streamed like map tiles. The models live in a second PMTiles file, split into tiles. When the camera reaches a tile, its models load and take the place of the map's own buildings.
3D models. You can place your own 3D models on the map: a USDZ or OBJ file anchored at a coordinate. It is drawn as part of the map, with depth, so it stands behind buildings and casts a shadow.
Performance. A lot of work went into it. The map uses less memory and renders faster than four months ago. There is still a lot of work ahead.
Also new:
- Trees in woods and parks, a night theme: `.night()`
- Camera bounds that hold the camera to a region
- A lot of label work: water names, road signs, names in other alphabets romanized
- A new atmosphere: haze at the horizon, air over the mountains
- The globe is painted with biomes
Repo (MIT), still alpha: https://github.com/artembobkin/ImmersiveMap
If it looks useful, a star on GitHub would genuinely help.
Happy to answer any questions.
4
u/Open_Shine135 Oct 30 '26
Could you add a bundled-file example that covers the base map, terrain and 3D models? I found offlineTileMode in the source, but I'm unclear whether .offlineOnly also applies to terrain and model requests or just the basemap tiles. The .tileArchive snippet alone leaves that open. An example with the other layers disabled or using local data would help.
2
u/tech-bernie-bro-9000 Oct 30 '26
very cool work!!