Get started

Install and set up

The Dart SDK is five pub packages released together. A Flutter app adds the ones it draws with, and a Dart server adds the pure ones.

Install the packages

In a Flutter app that shows a map:

flutter pub add mountaya_client mountaya_geo mountaya_elements_flutter

Add mountaya_navigation_flutter beside them for turn-by-turn navigation. On a Dart server or in a command-line tool:

dart pub add mountaya_client mountaya_admin

mountaya_admin mints session tokens, manages your organization and verifies webhooks. Only a server adds it.

Set up the platform

The map plugin needs iOS 15.5 and Android API level 24. The navigation plugin alone needs iOS 14.0. Raise the floors your app sets lower:

// android/app/build.gradle.kts
android {
    defaultConfig {
        minSdk = 24
    }
}

On iOS, set Minimum Deployments of the Runner target to 15.5 in Xcode, and platform :ios, '15.5' in ios/Podfile if your app uses CocoaPods.

A release build on Android reaches the network only with the INTERNET permission in android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

An app that locates its reader or navigates also declares location access. Navigation shows the lines.

Add your key

Put your publishable key in a .env file that git ignores:

MOUNTAYA_PUBLISHABLE_KEY=pk_your_publishable_key

Read it where the compiler sees it, and run with flutter run --dart-define-from-file=.env:

import 'package:mountaya_client/mountaya_client.dart';

// Compiled in from --dart-define-from-file=.env.
const publishableKey = String.fromEnvironment('MOUNTAYA_PUBLISHABLE_KEY');

final mountaya = Mountaya(credential: .publishable(key: publishableKey));
await mountaya.close();

A server reads its keys from the environment:

import 'dart:io';

import 'package:mountaya_client/mountaya_client.dart';

final server = Mountaya(
  credential: SecretCredential(Platform.environment['MOUNTAYA_SECRET_KEY'] ?? ''),
);
await server.close();

Create both keys under Organization → API keys in the Mountaya app.

Import the right package

ImportFor
package:mountaya_client/mountaya_client.dartMountaya, credentials, errors, streams
package:mountaya_client/rest_schema.dartMap Studio API types, as rest_schema
package:mountaya_client/data_schema.dartData API types, as data_schema
package:mountaya_client/tile_schema.dartTile API types, as tile_schema
package:mountaya_admin/mountaya_admin.dartadmin, webhook verification, on a server
package:mountaya_geo/mountaya_geo.dartUnits, formatting, profiles, search rules
package:mountaya_navigation_flutter/mountaya_navigation_flutter.dartDeviceNavigationEngine and its voice
package:mountaya_elements_flutter/mountaya_elements_flutter.dartMapEngine, MapView and every widget

The secret key and mountaya_admin belong on a server only.

Next steps

Last updated