使用响应本机链接的Google Map中的模式选项

卡洛斯

以下功能在驱动程序模式下打开地图。是否有任何选项可用于设置地图模式,例如驱动程序,交通工具等。

startNavigation(url) {
    Linking.canOpenURL(url).then(supported => {
      if (supported) {
        Linking.openURL(url);
      } else {
        console.log('Don\'t know how to open URI: ' + url);
      }
    });
  }
吉克森

检查此示例代码

import React, {
    Component
} from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Linking,
    TouchableHighlight,
} from 'react-native';

class StackOverflow extends Component {
    startNavigation(url) {
        Linking.canOpenURL(url).then(supported => {
            if (supported) {
                Linking.openURL(url);
            } else {
                console.log('Don\'t know how to open URI: ' + url);
            }
        });
    }

    _onPressButton(mode) {
        //driving d 
        //walking walking
        //bicycling bicycle
        //transit transit
        this.startNavigation("google.navigation:q=American Century Investments&mode="+mode);
    }

    render() {
        return (
            <View style={styles.container}>
                <TouchableHighlight onPress={this._onPressButton.bind(this,'d')}>
                    <Text>Driving</Text>
                </TouchableHighlight>
                <TouchableHighlight onPress={this._onPressButton.bind(this,'walking')}>
                    <Text>Walking</Text>
                </TouchableHighlight>
                <TouchableHighlight onPress={this._onPressButton.bind(this,'bicycle')}>
                    <Text>Bicycle</Text>
                </TouchableHighlight>
                <TouchableHighlight onPress={this._onPressButton.bind(this,'transit')}>
                    <Text>Transit</Text>
                </TouchableHighlight>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    }
});

AppRegistry.registerComponent('StackOverflow', () => StackOverflow);

在Android设备上验证

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章