为什么大姨妈迟迟不来| 珍珠状丘疹有什么危害| 公安局局长什么级别| 骨科什么意思| 七月二十九是什么星座| 彩宝是什么| 吃什么都拉肚子怎么回事| 核桃什么时候成熟| 拍脑部ct挂什么科| 什么的舞姿| 梦见绿豆是什么意思| 什么时候同房容易怀孕| 6月2日是什么星座| 高晓松为什么进监狱| 深入交流是什么意思| 鼻涕由清变黄说明什么| 脾胃不好有什么症状表现| 夏天做什么菜| 丰胸吃什么食物有效果| 鬼迷心窍是什么意思| 刘备字什么| 脸上长肉疙瘩是什么原因| 解语花是什么意思| 老年人爱出汗是什么原因| 专注力是什么意思| 随笔是什么意思| 荞麦和苦荞有什么区别| 菊花什么时候种植| 嗓子疼低烧吃什么药| 匪夷所思是什么意思| 副区长是什么级别| 肋骨骨折吃什么食物好得快| 牙龈疼吃什么消炎药| 胆固醇过高有什么危害| 考试前吃什么好| 人参和什么泡酒最好| 男人梦见蛇是什么意思| 男女之间的吸引靠什么| 什么有什么| peace什么意思| 器质性心脏病是什么意思| a型血和什么血型生出o型血| 血脂高吃什么药好| 什么叫缘分| 丙氨酸氨基转移酶是什么意思| 澳门打车用什么软件| 甲状腺肿物是什么意思| 什么是脑白质病变| 吐血是什么原因引起的| 摩羯座是什么星象| cml是什么意思| 七七事变是什么生肖| 右手中指指尖麻木是什么原因| 梦见自己生了个儿子是什么意思| 脚底红是什么原因| 氨纶是什么面料| 如鱼得水是什么意思| 月经推后是什么原因引起| 肠道菌群失调有什么症状| 标新立异是什么意思| 锦鲤是什么意思| 阴茎硬度不够吃什么好| 慢性鼻窦炎吃什么药| 涉黑是什么意思| 右耳朵耳鸣是什么原因| 湿疹是由什么引起的| 什么叫甲亢| 卵泡不破是什么原因造成的| ab型和b型生的孩子是什么血型| 肿瘤标志物cA724高说明什么| 手脱皮缺什么维生素| 特需号是什么意思| 苦夏什么意思| 吃什么降血脂和胆固醇| 霉菌性阴道炎用什么栓剂| zf是什么意思| 灿字五行属什么| 吃茄子对身体有什么好处| 每次睡觉都做梦为什么| 肚子一直咕咕叫是什么原因| 输卵管堵塞是什么原因造成的| 什么牌奶粉好| 双肾囊肿什么意思| syphilis是什么意思| 属羊人佩戴什么旺自己| bunny是什么意思| 处大象是什么意思| 香蕉与什么食物相克| 地级市副市长是什么级别| 螺旋菌感染有什么危害| 白话文是什么意思| 夏天手上长小水泡是什么原因| 10.31什么星座| 内分泌失调是什么| 孩子为什么不愿意上学| 字字珠玑什么意思| 小龙虾和什么不能一起吃| 土地出让金是什么意思| 眼前有亮光闪是什么问题| 感冒了能吃什么水果| 虾不能和什么食物一起吃| 深千尺是什么意思| 草莓什么季节种植| 六月初一什么日子| 什么是静脉血栓| 什么水解酒| 有机蔬菜是什么意思| 繁星是什么意思| 潜阳是什么意思| 正常人尿液是什么颜色| 吃什么对胃好养胃的食物| 屠苏是什么意思| 翡翠五行属什么| 生眼屎是什么原因引起的| 梦见自己生病住院了是什么意思| 神经官能症是什么病| 离婚都需要什么手续和证件| 11月5日是什么星座| 透明隔间腔是什么意思| 有点想吐是什么原因| 生气会得什么病| 为什么心里总想一个人| 什么的世界| 男生第一次什么感觉| 溜肩是什么意思| 往生净土是什么意思| 什么牌子的燃气灶质量好| 翊字是什么意思| 补办护照需要什么材料| 中毒了吃什么解毒| 桃花什么时候开花| 留低是什么意思| 咽喉炎吃什么药| 梦中梦是什么原因| 眼睛经常充血是什么原因引起的| 玉鸟吃什么饲料好| 大便潜血弱阳性是什么原因| 上眼皮突然肿了是什么原因| 测骨龄去医院挂什么科| 思维敏捷是什么意思| 咒语是什么意思| 典型是什么意思| 唐僧成了什么佛| 羊水穿刺检查什么| 肠胃不好挂什么科| 吐口水有血是什么原因| 84消毒液不能和什么一起用| dq什么意思| 一路卷风迎大年是什么生肖| 西米是什么东西做的| 大排畸主要检查什么| 刺史相当于现在的什么官| 瞬移是什么意思| 吃什么能治白头发| 癌胚抗原偏高说明什么| 款款是什么意思| 肝火胃火旺盛吃什么药| 不复相见什么意思| 嘴角上火是什么原因| 百衲衣是什么意思| eb病毒是什么| 护士是什么专业| 什么原因造成高血压| 减肥吃什么肉| 夏季吃桃子有什么好处| 痱子粉和爽身粉有什么区别| 辰时是什么时候| 每天吃一根黄瓜有什么好处| 乙肝检查挂什么科| 黄连是什么| 黄油是用什么做的| 大快朵颐是什么意思| 大油边是什么| p0s是什么意思| 口什么腹什么| 忌作灶是什么意思| 宫后是牛身上什么部位| get什么意思| 命运是什么意思| 眉什么眼什么| pending是什么状态| 吃什么会变黑| 每天喝一杯豆浆有什么好处| kenzo是什么牌子| 左肋骨下方是什么器官| 腰扭伤挂什么科| 什么是普惠性幼儿园| 斛什么意思| 女性乳房痒是什么原因| 子宫肌瘤吃什么药好| 调教什么意思| 肚子右边是什么部位| 什么情况下会猝死| 哪吒为什么叫哪吒| 接亲是什么意思| 国民党为什么会失败| 牙龈发炎肿痛吃什么药| 拔智齿后要注意什么| 头发黄是什么原因| 腺肌症有什么症状| 胆水是什么| 阿玛尼手表算什么档次| 得令是什么意思| 百香果是什么季节的水果| 曹操为什么要杀华佗| 珊五行属什么| 拔罐之后要注意什么| 9月16日是什么星座| 疱疹不能吃什么食物| 争议是什么意思| 书生是什么意思| 50是什么意思| 谈婚论嫁什么意思| 特仑苏是什么意思| 感冒了吃什么水果比较好| 疙瘩是什么意思| 201是什么意思| 卟啉病是什么病| 农历10月26日是什么星座| rock是什么意思| ercp是什么检查| 孩子发烧肚子疼是什么原因| 蹲久了站起来头晕是什么原因| 男人忽冷忽热说明什么| 阿尔茨海默症吃什么药| 囊肿是什么| 吃什么补精最快| gigi 是什么意思| 涵字属于五行属什么| 拉肚子用什么药| 一生一世是什么意思| 肺部微结节是什么意思| 羸弱什么意思| 回头是岸是什么意思| 奇异果是什么水果| 脑壳疼是什么原因| 酸西地那非片是什么药| 避孕套和安全套有什么区别| 无妄之灾什么意思| 虎鼠不结亲是什么意思| 武松是什么生肖| 欲代表什么生肖| 九寨沟属于什么市| 为什么会经常口腔溃疡| dmd是什么病| 缜密是什么意思| 皑皑是什么意思| 重力是什么| 什么感冒药效果最好| 金字旁加者念什么| 下面痒用什么清洗最好| 什么是断掌| 猫不能吃什么| 夜宵吃什么| 什么山| 何五行属什么| 胸膜炎是什么症状| 霍山石斛有什么作用| 肚子疼拉肚子吃什么药| 月经多是什么原因| 山西属于什么地区| 阴历六月是什么月| 梅艳芳什么病| 果可以加什么偏旁| 百度
Skip to content

googlemaps/react-native-navigation-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?

Repository files navigation

Google Navigation for React Native (Beta)

European Economic Area (EEA) developers

If your billing address is in the European Economic Area, effective on 8 July 2025, the Google Maps Platform EEA Terms of Service will apply to your use of the Services. Functionality varies by region. Learn more.

Description

This repository contains a React Native plugin that provides a Google Navigation component for building native Android and iOS apps using React.

Note

This package is in Beta until it reaches version 1.0. According to semantic versioning, breaking changes may be introduced before 1.0.

Requirements

Android iOS
Minimum mobile OS supported SDK 23+ iOS 15.0+

Important

Apply API restrictions to the API key to limit usage to "Navigation SDK, "Maps SDK for Android", and "Maps SDK for iOS" for enhanced security and cost management. This helps guard against unauthorized use of your API key.

Installation

This package is listed on NPM as @googlemaps/react-native-navigation-sdk. Install it with:

npm i @googlemaps/react-native-navigation-sdk

In your TSX or JSX file, import the components you need:

import { NavigationView } from '@googlemaps/react-native-navigation-sdk';

Android

Disable new architecture

This package does not yet support new architecture. Make sure new architecture is disabled in your android/gradle.properties file:

newArchEnabled=false

Enable Jetifier

To ensure compatibility with AndroidX, enable Jetifier in your android/gradle.properties file:

# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

Minimum SDK Requirements for Android

The minSdkVersion for your Android project must be set to 23 or higher in android/app/build.gradle:

android {
    defaultConfig {
        minSdkVersion 23
    }
}

If minSdkVersion is set to less than 34 (API 34), you need to configure desugaring for your Android app. To enable desugaring, add the following configurations to android/app/build.gradle file:

android {
    ...
    compileOptions {
        coreLibraryDesugaringEnabled true
        ...
    }
}

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.0.4'
}

You may also need to upgrade to Gradle 8.4 and the Android Gradle plugin version 8.3.0

Set Google Maps API Key

To securely store your API key, it is recommended to use the Google Maps Secrets Gradle Plugin. This plugin helps manage API keys without exposing them in your app's source code.

See example configuration for secrets plugin at example applications build.gradle file.

iOS

Disable new architecture

This package does not yet support new architecture. Make sure new architecture is disabled in your ios/Podfile:

ENV['RCT_NEW_ARCH_ENABLED'] = '0'

Set Google Maps API Key

To set up, specify your API key in the application delegate ios/Runner/AppDelegate.m:

#import <GoogleMaps/GoogleMaps.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [GMSServices provideAPIKey:@"API_KEY"];
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

Usage

Initializing Navigation

Wrap application with the NavigationProvider component. This will provide the necessary context for navigation throughout your app.

import React from 'react';
import {
  NavigationProvider,
  TaskRemovedBehavior,
  type TermsAndConditionsDialogOptions,
} from '@googlemaps/react-native-navigation-sdk';

const termsAndConditionsDialogOptions: TermsAndConditionsDialogOptions = {
  title: 'Terms and Conditions Title',
  companyName: 'Your Company Name',
  showOnlyDisclaimer: true,
};

const App = () => {
  return (
    <NavigationProvider
      termsAndConditionsDialogOptions={termsAndConditionsDialogOptions}
      taskRemovedBehavior={TaskRemovedBehavior.CONTINUE_SERVICE}
    >
      {/* Add your application components here */}
    </NavigationProvider>
  );
};

export default App;

Task Removed Behavior

The taskRemovedBehavior prop defines how the navigation should behave when a task is removed from the recent apps list on Android. It can either:

  • CONTINUE_SERVICE: Continue running in the background. (default)
  • QUIT_SERVICE: Shut down immediately.

This prop has only an effect on Android.

Using NavigationController

You can use the useNavigation hook to access the NavigationController and control navigation within your components. The useNavigation hook also provides methods to add and remove listeners.

Initializing Navigation

...
const { navigationController } = useNavigation();

const initializeNavigation = useCallback(async () => {
  try {
    await navigationController.init();
    console.log('Navigation initialized');
  } catch (error) {
    console.error('Error initializing navigation', error);
  }
}, [navigationController]);

Note

Navigation can be controlled separately from the navigation views allowing navigation to be started and stopped independently.

Starting Navigation

To start navigation, set a destination and start guidance:

try {
  const waypoint = {
    title: 'Destination',
    position: {
      lat: 37.4220679,
      lng: -122.0859545,
    },
  };

  const routingOptions = {
    travelMode: TravelMode.DRIVING,
    avoidFerries: false,
    avoidTolls: false,
  };

  const displayOptions: DisplayOptions = {
    showDestinationMarkers: true,
    showStopSigns: true,
    showTrafficLights: true,
  };

  await navigationController.setDestinations([waypoint], routingOptions, displayOptions);
  await navigationController.startGuidance();
} catch (error) {
  console.error('Error starting navigation', error);
}

Adding navigation listeners

const { navigationController, addListeners, removeListeners } = useNavigation();

const onArrival = useCallback((event: ArrivalEvent) => {
    if (event.isFinalDestination) {
        console.log('Final destination reached');
        navigationController.stopGuidance();
    } else {
        console.log('Continuing to the next destination');
        navigationController.continueToNextDestination();
        navigationController.startGuidance();
    }
}, [navigationController]);

const navigationCallbacks = useMemo(() => ({
    onArrival,
    // Add other callbacks here
}), [onArrival]);

useEffect(() => {
    addListeners(navigationCallbacks);
    return () => {
        removeListeners(navigationCallbacks);
    };
}, [navigationCallbacks, addListeners, removeListeners]);

See NavigationCallbacks interface for a list of available callbacks.

When removing listeners, ensure you pass the same object that was used when adding them, as multiple listeners can be registered for the same event.

Add a navigation view

You can now add a NavigationView component to your application..

The view can be controlled with the ViewController (Navigation and MapView) that are retrieved from the onMapViewControllerCreated and onNavigationViewControllerCreated (respectively).

The NavigationView compoonent should be used within a View with a bounded size. Using it in an unbounded widget will cause the application to behave unexpectedly.

// Permissions must have been granted by this point.

<NavigationView
    androidStylingOptions={{
        primaryDayModeThemeColor: '#34eba8',
        headerDistanceValueTextColor: '#76b5c5',
        headerInstructionsFirstRowTextSize: '20f',
    }}
    iOSStylingOptions={{
        navigationHeaderPrimaryBackgroundColor: '#34eba8',
        navigationHeaderDistanceValueTextColor: '#76b5c5',
    }}
    navigationViewCallbacks={navigationViewCallbacks}
    mapViewCallbacks={mapViewCallbacks}
    onMapViewControllerCreated={setMapViewController}
    onNavigationViewControllerCreated={setNavigationViewController}
    termsAndConditionsDialogOptions={termsAndConditionsDialogOptions}
/>

Add a map view

You can also add a bare MapView that works as a normal map view without navigation functionality. MapView only need a MapViewController to be controlled.

<MapView
    mapViewCallbacks={mapViewCallbacks}
    onMapViewControllerCreated={setMapViewController}
/>

Requesting and handling permissions

The Google Navigation SDK React Native library offers functionalities that necessitate specific permissions from the mobile operating system. These include, but are not limited to, location services, background execution, and receiving background location updates.

Note

The management of these permissions falls outside the scope of the Navigation SDKs for Android and iOS. As a developer integrating these SDKs into your applications, you are responsible for requesting and obtaining the necessary permissions from the users of your app.

You can see example of handling permissions in the app.tsx file of the sample application:

import {request, PERMISSIONS, RESULTS} from 'react-native-permissions';

// ...

// Request permission for accessing the device's location.
const requestPermissions = async () => {
    const result = await request(
        Platform.OS === "android" ?
            PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION :
            PERMISSIONS.IOS.LOCATION_ALWAYS,
    );

    if (result === RESULTS.GRANTED) {
        setArePermissionsApproved(true);
    } else {
        Snackbar.show({
            text: 'Permissions are needed to proceed with the app. Please re-open and accept.',
            duration: Snackbar.LENGTH_SHORT,
        });
    }
};

Changing the NavigationView size

By default, NavigationView uses all the available space provided to it. To adjust the size of the NavigationView, use the style prop.

    <NavigationView
        style={{width: 200, height: 50%}}
        ...
    />

Sample application

See the example directory for a complete navigation sample app.

Support for Android Auto and Apple CarPlay

This plugin is compatible with both Android Auto and Apple CarPlay infotainment systems. For more details, please refer to the respective platform documentation:

Known issues

Compatibility with other libraries

This package uses the Google Maps Navigation SDK for Android and iOS, which includes a dependency on the Google Maps SDK. If your project includes other React Native libraries with Google Maps SDK dependencies, you may encounter build errors due to version conflicts. To avoid this, it's recommended to avoid using multiple packages with Google Maps dependencies.

Note

This package provides a MapView component, which can be used as a classic Google Maps view without navigation. See Add a map view for details.

Contributing

See the Contributing guide.

Terms of Service

This library uses Google Maps Platform services. Use of Google Maps Platform services through this library is subject to the Google Maps Platform Terms of Service.

This library is not a Google Maps Platform Core Service. Therefore, the Google Maps Platform Terms of Service (e.g. Technical Support Services, Service Level Agreements, and Deprecation Policy) do not apply to the code in this library.

Support

This package is offered via an open source license. It is not governed by the Google Maps Platform Support Technical Support Services Guidelines, the SLA, or the Deprecation Policy (however, any Google Maps Platform services used by the library remain subject to the Google Maps Platform Terms of Service).

This package adheres to semantic versioning to indicate when backwards-incompatible changes are introduced. Accordingly, while the library is in version 0.x, backwards-incompatible changes may be introduced at any time.

If you find a bug, or have a feature request, please file an issue on GitHub. If you would like to get answers to technical questions from other Google Maps Platform developers, ask through one of our developer community channels. If you'd like to contribute, please check the Contributing guide.

不什么不什么的四字词语 胃幽门螺旋杆菌吃什么药效果好 菖蒲是什么 康庄大道是什么意思 子宫直肠窝积液是什么意思
vogue是什么意思 老年人腿肿是什么原因引起的 氯化钾是什么东西 腰肌劳损有什么症状 做梦梦见兔子是什么意思
为什么不 12月1日什么星座 百合吃了有什么好处 儿童看牙齿挂什么科 女性尿酸低是什么原因
草木皆兵是什么意思 喝酒后手麻是什么原因 什么是奇点 小雪时节吃什么 氯雷他定片什么时候吃
什么是黑色素肿瘤hcv9jop0ns5r.cn 农历6月20日是什么星座hcv9jop3ns1r.cn 什么是筋膜hcv8jop4ns6r.cn 猫砂是什么hcv9jop5ns8r.cn 为什么一吃完饭就肚子疼hcv8jop1ns9r.cn
aug是什么意思hcv9jop2ns8r.cn 胆结石吃什么最好hcv9jop7ns2r.cn 博士生导师是什么级别hcv9jop2ns8r.cn 一什么虫子hcv9jop6ns9r.cn 鼻涕倒流吃什么药hcv8jop4ns2r.cn
口腔溃疡是什么原因hcv7jop7ns3r.cn 癞蛤蟆吃什么hcv8jop9ns3r.cn 今天有什么新闻hcv9jop6ns8r.cn 伤官格是什么意思hcv8jop5ns0r.cn 蛋白烫发是什么意思hcv8jop7ns1r.cn
莱昂纳多为什么叫小李子hcv9jop5ns4r.cn 白羊座上升星座是什么hcv8jop1ns0r.cn 吃苹果有什么好处和功效hcv9jop1ns8r.cn 乙肝五项45阳性是什么意思hcv9jop5ns2r.cn 喝红酒对身体有什么好处hcv8jop5ns4r.cn
百度