This repository contains the reference applications for GLMap SDK 2.2.0. They use Swift Package Manager and the public GLMap binary frameworks.
- Open
SwiftDemo/SwiftDemo.xcodeprojin Xcode. - Get an API key from the GLMap User Dashboard.
- Replace
YOUR_API_KEYlocally in the application you want to run (do not commit a real key):SwiftDemo/SwiftDemo/AppDelegate.swiftfor the UIKit catalog;SwiftDemo/SwiftUIDemo/SwiftUIDemoApp.swiftfor the SwiftUI example.
- Select an iOS simulator or device and run one of the schemes below.
Xcode downloads the GLMap package and binary frameworks when it resolves package dependencies for the first time.
SwiftDemo is the UIKit reference application for iOS 15 and later. The catalog contains compact, self-contained examples for:
- map setup, styles, camera animation, and 3D terrain;
- images, markers, tracks, GeoJSON, and user location;
- online and offline search;
- online and offline routing;
- downloading maps and related offline data.
Each catalog screen focuses on one API and keeps setup next to the code that uses it. The Demo Mode button above the catalog runs one continuous, 26-second story on the Amalfi Coast: explore the map with contour lines, find a restaurant, reveal a walking route, then follow a simulated walker in 3D. The traversed route turns grey using GLMapTrack.progressIndex and progressColor; the camera and marker share the same distance-based timeline. The walking segment is explicitly labeled as an accelerated route preview, not real GPS navigation. It uses real online search results and routing data; the compact UI and animated markers are part of the demo app, not SDK-provided controls. Tap anywhere to return to the catalog. The individual screens remain the code examples to learn from.
The SwiftDemo scheme includes simulator tests for screen lifecycle, bundled offline data, GeoJSON loading, and Demo Mode layout. Run them with Product → Test in Xcode; no API key is needed for these checks.
The timeline, distance-based track progress, and heading interpolation have standalone tests that do not require UIKit, an API key, or a simulator:
swiftc SwiftDemo/SwiftDemo/DemoMode/DemoTourMotion.swift tests/DemoTourMotionTests.swift -o /tmp/demo-motion-tests
/tmp/demo-motion-testsAll map markers — restaurants, start, arrival ring, and the simulated walker — use native GLMapImage drawables that account for terrain height. UIKit is used only for screen-space captions and panels. The grey traversed prefix is the same native track, recolored through progressIndex / progressColor. Camera bearing is spatially smoothed and interpolated along the shortest angular path; mapOrigin keeps the walker below screen center. No location-manager permission or real GPS feed is involved.
SwiftUIDemo is a minimal SwiftUI integration for iOS 16.2 and later. It wraps GLMapView with UIViewRepresentable, keeps the map center in a SwiftUI binding, and handles map taps without adding an application-specific architecture layer.
- Both apps check the Boolean result of
GLMapManager.activate(apiKey:)before using the SDK. A failure means resource/storage initialization failed; this does not validate the API key. GLMapSwiftre-exports the Core Swift conveniences, so existingimport GLMap/import GLMapSwiftclients continue to work with the modular SDK.GeoJSONDemohandles the result passed tosetVectorObjectscompletion:.ready,.superseded,.cancelled, or.failed. Updates and completions run on the main thread;.readymeans geometry is ready to draw, not that a frame has been presented. Examples that do not need the outcome omit the completion.