Skip to main content

Get started

Create an API key at user.globus.software/apps, then choose a platform. The examples use Porto as the initial map position.

iOS

GLMap 2.0 uses Swift Package Manager as its reference iOS integration.

Add the package

In Xcode, select File → Add Package Dependencies and enter:

https://github.com/GLMap/GLMapSwift.git

Select Up to Next Major Version starting at 2.0.0. Add these products as needed:

  • GLMap — map rendering and Swift extensions
  • GLSearch — online and offline search
  • GLRoute — online and offline routing

For a manifest-based project:

.package(
url: "https://github.com/GLMap/GLMapSwift.git",
from: "2.0.0"
)

Activate GLMap

Call activation once before creating a map view:

import GLMap
import GLMapSwift
import UIKit

@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GLMapManager.activate(apiKey: "YOUR_API_KEY")
GLMapManager.shared.tileDownloadingAllowed = true
return true
}
}

Online tile downloading is disabled by default. Keep it disabled in an offline-only application.

Display a map

GLMapView automatically loads DefaultStyle.bundle from the SPM resources configured during activation:

import GLMap
import GLMapSwift
import UIKit

final class MapViewController: UIViewController {
private let map = GLMapView()

override func viewDidLoad() {
super.viewDidLoad()

map.frame = view.bounds
map.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(map)

map.mapGeoCenter = GLMapGeoPoint(lat: 41.1579, lon: -8.6291)
map.mapZoomLevel = 12
}
}

Use GLMapStyleParser only to load a custom style or change style options. See Your first map.

The complete reference project is SwiftDemo.

CocoaPods

CocoaPods remains available for existing Objective-C integrations. New Swift applications should use Swift Package Manager.

Android

The GLMap 2.0 reference project uses Kotlin, compileSdk 37, and targetSdk 37. The libraries support Android API 21 and later.

Add the repository and dependencies

In settings.gradle:

dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = uri("https://maven.globus.software/artifactory/libs") }
}
}

In the application module's build.gradle:

android {
compileSdk 37

defaultConfig {
minSdk 21
targetSdk 37
}
}

dependencies {
implementation "globus:glmap:2.0.0"
implementation "globus:glsearch:2.0.0" // optional
implementation "globus:glroute:2.0.0" // optional
}

globus:glmap:2.0.0 pulls the matching default style automatically. Do not add a separate style version.

Activate GLMap

import android.app.Application
import globus.glmap.GLMapManager
import globus.glsearch.GLSearch

class App : Application() {
override fun onCreate() {
super.onCreate()

check(GLMapManager.Initialize(this, "YOUR_API_KEY", null)) {
"GLMap initialization failed. Check the API key and free storage."
}
GLMapManager.SetTileDownloadingAllowed(true)

// Required only when the application uses GLSearch.
GLSearch.Initialize(this)
}
}

Register the class in AndroidManifest.xml:

<application
android:name=".App"
... />

Display a map

Android loads the default style when GLMapView is created:

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import globus.glmap.GLMapView
import globus.glmap.MapGeoPoint

class MapActivity : AppCompatActivity() {
private lateinit var map: GLMapView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

map = GLMapView(this)
setContentView(map)
map.renderer.mapGeoCenter = MapGeoPoint(41.1579, -8.6291)
map.renderer.mapZoom = 12.0
}

override fun onDestroy() {
map.dispose()
super.onDestroy()
}
}

The complete reference project is kotlinDemo.

Next steps