使用React Native Google地图路线包自动启动导航 [英] Auto start navigation with React Native Google Maps Directions package
问题描述
我有一个要求,在加载谷歌地图应用程序时,必须自动启动导航。
当前场景 - 显示路线,但用户必须单击 start
开始导航
我找不到与之相关的任何标志?
谷歌地图官方文档显示使用它作为 dir_action = navigate
但我对如何将它翻译成 react-native-google -maps-directions
package
任何想法我们如何解决这个问题?
react-native-maps-directions 使用Directions API显示路线。请注意,Directions API不包含任何实时导航,仅用于显示路线。此外,Google Maps API还禁止实时导航。
查看Google Maps API服务条款第10.4(c,iii)段。它读取
没有导航。您不会将服务或内容用于或与(a)实时导航或路线指引;或者(b)自动或自动控制车辆。
来源: https://developers.google.com/maps/terms#10-license-restrictions
为了符合Google Maps API服务条款,您应该使用导航模式下的Google地图网址。
var url =https://www.google.com/maps/dir/?api=1&travelmode=driving& ; dir_action =导航&安培;目的地=洛矶+;
Linking.canOpenURL(url).then(supported => {
if(!supported){
console.log('不能处理url:'+ url);
} else {
return Linking.openURL(url);
}
})。catch(err => console.error('An error occurred',err)) ;
我希望这有助于您!
I have a requirement that on loading the google map application, have to automatically start the navigation.
Current scenario - It shows the route but user has to click on start
to start navigation
I couldn't find any flag associated for the same?
Found this article which shows the flags used in google maps
Official google maps docs shows to use it as dir_action=navigate
but I am clueless on how to translate it into react-native-google-maps-directions
package
Any idea how could we approach the problem?
The react-native-maps-directions uses the Directions API to display routes. Please note that Directions API doesn't include any real-time navigation, it is meant only to show routes. The real-time navigation additionally is prohibited in the Google Maps APIs.
Have a look at the Google Maps API Terms of Service paragraph 10.4 (c, iii). It reads
No navigation. You will not use the Service or Content for or in connection with (a) real-time navigation or route guidance; or (b) automatic or autonomous vehicle control.
source: https://developers.google.com/maps/terms#10-license-restrictions
In order to be compliant with Google Maps API Terms of Service you should open the Google Maps app installed in your device using the Google Maps URLs in navigation mode.
var url = "https://www.google.com/maps/dir/?api=1&travelmode=driving&dir_action=navigate&destination=Los+Angeles";
Linking.canOpenURL(url).then(supported => {
if (!supported) {
console.log('Can\'t handle url: ' + url);
} else {
return Linking.openURL(url);
}
}).catch(err => console.error('An error occurred', err));
I hope this helps!
这篇关于使用React Native Google地图路线包自动启动导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!