RoutePlanScreen.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { StackScreenProps } from '@react-navigation/stack';
  2. import * as React from 'react';
  3. import { Div, Button, Image, Text, Avatar } from 'react-native-magnus';
  4. import { ScrollView } from 'react-native-gesture-handler';
  5. import { WebView } from 'react-native-webview';
  6. import { useTranslation } from 'react-i18next';
  7. import { useMount } from 'ahooks';
  8. import * as Linking from 'expo-linking';
  9. import {
  10. toastShow,
  11. toastHide,
  12. toastInfo,
  13. toastSuccess,
  14. } from '../utils/SystemUtils';
  15. import useModel from 'flooks';
  16. import MapModel from './model';
  17. import { tengxunKey } from '../utils/MapUtils';
  18. export default function RoutePlanScreen({ navigation, route }) {
  19. const { t } = useTranslation();
  20. const { getNowLocation } = useModel(MapModel, []);
  21. const [mapUrl, setmapUrl] = React.useState<string>('');
  22. const { params } = route;
  23. const { toName, tocoord } = params;
  24. useMount(() => {
  25. toastShow();
  26. console.log(params);
  27. getNowLocation().then((res) => {
  28. let location = '';
  29. if (res.addressName !== '定位失败') {
  30. location = `${res.location.lat},${res.location.lng}`;
  31. }
  32. // setmapUrl(
  33. // `https://apis.map.qq.com/uri/v1/routeplan?type=drive&fromcoord=${location}&to=${toName}&tocoord=${tocoord}&policy=1&referer=${tengxunKey}`
  34. // );
  35. toastHide();
  36. });
  37. });
  38. return (
  39. <>
  40. {/* {!!mapUrl && (
  41. <WebView
  42. source={{
  43. uri: mapUrl,
  44. }}
  45. style={{ flexGrow: 1, width: '100%' }}
  46. />
  47. )} */}
  48. </>
  49. );
  50. }